~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Michael Hudson
  • Date: 2008-03-06 01:59:26 UTC
  • mto: This revision was merged to the branch mainline in revision 149.
  • Revision ID: michael.hudson@canonical.com-20080306015926-ffmx4znpbcaw80lg
1.2.1 administrivia

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
#
19
19
 
20
 
from loggerhead.controllers import TemplatedBranchView
21
 
 
22
 
 
23
 
class AtomUI (TemplatedBranchView):
24
 
 
25
 
    template_path = 'loggerhead.templates.atom'
26
 
 
27
 
    def get_values(self, h, args, kw, headers):
28
 
 
29
 
        pagesize = int(20)#self._branch.config.get('pagesize', '20'))
30
 
 
31
 
        revid_list = h.get_file_view(h.last_revid, None)
32
 
        entries = list(h.get_changes(list(revid_list)[:pagesize]))
33
 
 
34
 
        headers['Content-Type'] = 'application/atom+xml'
35
 
        return {
36
 
            'changes': entries,
37
 
            'updated': entries[0].date.isoformat() + 'Z',
38
 
        }
 
20
import turbogears
 
21
 
 
22
from loggerhead import util
 
23
 
 
24
 
 
25
class AtomUI (object):
 
26
    
 
27
    def __init__(self, branch):
 
28
        # BranchView object
 
29
        self._branch = branch
 
30
        self.log = branch.log
 
31
 
 
32
    @turbogears.expose(template='loggerhead.templates.atom', format="xml", content_type="application/atom+xml")
 
33
    def default(self, *args):
 
34
        h = self._branch.get_history()
 
35
 
 
36
        h._branch.lock_read()
 
37
        try:
 
38
            pagesize = int(self._branch.config.get('pagesize', '20'))
 
39
 
 
40
            revid_list = h.get_file_view(h.last_revid, None)
 
41
            entries = list(h.get_changes(list(revid_list)[:pagesize]))
 
42
 
 
43
            vals = {
 
44
                'branch': self._branch,
 
45
                'changes': entries,
 
46
                'util': util,
 
47
                'history': h,
 
48
                'updated': entries[0].date.isoformat() + 'Z',
 
49
            }
 
50
            h.flush_cache()
 
51
            return vals
 
52
        finally:
 
53
            h._branch.unlock()