~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Robey Pointer
  • Date: 2006-12-15 11:10:23 UTC
  • Revision ID: robey@lag.net-20061215111023-brrb46658dljz9x4
fix a couple of bugs:
- merged in/from lines should be broken up on multiple lines (some of mpool's
  bzr.dev revisions have dozens of merged-ins)
- navigation footer shouldn't be displayed if there's only 1 page
- changes list by file wasn't calculated correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import turbogears
21
21
 
22
22
from loggerhead import util
23
 
from loggerhead.templatefunctions import templatefunctions
24
23
 
25
24
 
26
25
class AtomUI (object):
27
26
    
28
 
    def __init__(self, branch):
29
 
        # BranchView object
30
 
        self._branch = branch
31
 
        self.log = branch.log
32
 
 
33
 
    @turbogears.expose(template='zpt:loggerhead.templates.atom',
34
 
                       format="xml", content_type="application/atom+xml")
35
 
    def default(self, *args, **kwargs):
36
 
        h = self._branch.get_history()
37
 
 
38
 
        h._branch.lock_read()
39
 
        try:
40
 
            pagesize = int(self._branch.config.get('pagesize', '20'))
41
 
 
42
 
            revid_list = h.get_file_view(h.last_revid, None)
43
 
            entries = list(h.get_changes(list(revid_list)[:pagesize]))
44
 
 
45
 
            vals = {
46
 
                'branch': self._branch,
47
 
                'changes': entries,
48
 
                'util': util,
49
 
                'history': h,
50
 
                'updated': entries[0].date.isoformat() + 'Z',
51
 
            }
52
 
            vals.update(templatefunctions)
53
 
            h.flush_cache()
54
 
            return vals
55
 
        finally:
56
 
            h._branch.unlock()
 
27
    @turbogears.expose(template='loggerhead.templates.atom', format="xml", content_type="application/atom+xml")
 
28
    def default(self, *args):
 
29
        h = util.get_history()
 
30
 
 
31
        # really, there is no point giving a revid here...
 
32
        if len(args) > 0:
 
33
            revid = args[0]
 
34
        else:
 
35
            revid = h.last_revid
 
36
        revlist = h.get_short_revision_history_from(revid)
 
37
        entries = list(h.get_changelist(list(revlist)[:20]))
 
38
 
 
39
        vals = {
 
40
            'external_url': util.get_config().get('external_url'),
 
41
            'branch_name': util.get_config().get('branch_name'),
 
42
            'changes': entries,
 
43
            'util': util,
 
44
            'history': h,
 
45
            'scan_url': '/changes',
 
46
            'updated': entries[0].date.isoformat() + 'Z',
 
47
        }
 
48
        h.flush_cache()
 
49
        return vals