~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Jelmer Vernooij
  • Date: 2008-08-05 16:07:16 UTC
  • mto: (197.1.9 pathargs)
  • mto: This revision was merged to the branch mainline in revision 202.
  • Revision ID: jelmer@samba.org-20080805160716-t5e654so9aj08g85
Improve whatis.

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
 
import cherrypy
21
 
import turbogears
22
 
 
23
 
from loggerhead import util
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='loggerhead.templates.atom', format="xml", content_type="application/atom+xml")
34
 
    def default(self, *args):
35
 
        h = self._branch.get_history()
36
 
 
37
 
        h._branch.lock_read()
38
 
        try:
39
 
            pagesize = int(self._branch.config.get('pagesize', '20'))
40
 
 
41
 
            revid_list = h.get_file_view(h.last_revid, None)
42
 
            entries = list(h.get_changes(list(revid_list)[:pagesize]))
43
 
 
44
 
            vals = {
45
 
                'branch': self._branch,
46
 
                'changes': entries,
47
 
                'util': util,
48
 
                'history': h,
49
 
                'updated': entries[0].date.isoformat() + 'Z',
50
 
            }
51
 
            h.flush_cache()
52
 
            return vals
53
 
        finally:
54
 
            h._branch.unlock()
 
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
        }