~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-06-18 04:31:25 UTC
  • Revision ID: michael.hudson@canonical.com-20080618043125-zlm8jjui5xqe4p54
comment out obsolete test

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
 
        pagesize = int(20)#self._branch.config.get('pagesize', '20'))
29
 
 
30
 
        revid_list = h.get_file_view(h.last_revid, None)
31
 
        entries = list(h.get_changes(list(revid_list)[:pagesize]))
32
 
 
33
 
        headers['Content-Type'] = 'application/atom+xml'
34
 
        return {
35
 
            'changes': entries,
36
 
            'updated': entries[0].date.isoformat() + 'Z',
37
 
        }
 
20
import turbogears
 
21
 
 
22
from loggerhead import util
 
23
from loggerhead.templatefunctions import templatefunctions
 
24
 
 
25
 
 
26
class AtomUI (object):
 
27
    
 
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
            return vals
 
54
        finally:
 
55
            h._branch.unlock()