~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-11 06:44:19 UTC
  • Revision ID: robey@lag.net-20061211064419-8ssa7mlsiflpmy0c
initial checkin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# Copyright (C) 2006  Robey Pointer <robey@lag.net>
3
 
# Copyright (C) 2006  Goffredo Baroncelli <kreijack@inwind.it>
4
3
#
5
4
# This program is free software; you can redistribute it and/or modify
6
5
# it under the terms of the GNU General Public License as published by
17
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
17
#
19
18
 
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 {
 
19
import turbogears
 
20
 
 
21
from loggerhead.history import History
 
22
from loggerhead import util
 
23
 
 
24
 
 
25
FOLDER = '/Users/robey/code/paramiko/paramiko'
 
26
BRANCH_NAME = 'paramiko-dev'
 
27
EXTERNAL_URL = 'http://localhost:8080'
 
28
 
 
29
class AtomUI (object):
 
30
 
 
31
    @turbogears.expose(template='loggerhead.templates.atom', format="xml", content_type="application/atom+xml")
 
32
    def default(self, *args):
 
33
        h = History.from_folder(FOLDER)
 
34
        if len(args) > 0:
 
35
            revid = args[0]
 
36
        else:
 
37
            revid = h.last_revid
 
38
        revlist = h.get_short_revision_history_from(revid)
 
39
        entries = list(h.get_changelist(list(revlist)[:20]))
 
40
 
 
41
        vals = {
 
42
            'external_url': EXTERNAL_URL,
 
43
            'branch_name': BRANCH_NAME,
35
44
            'changes': entries,
 
45
            'util': util,
 
46
            'history': h,
 
47
            'scan_url': '/changes',
36
48
            'updated': entries[0].date.isoformat() + 'Z',
37
49
        }
 
50
        return vals