~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Martin Pool
  • Date: 2009-03-10 01:05:08 UTC
  • mfrom: (262.2.6 loggerhead-plugin)
  • Revision ID: mbp@sourcefrog.net-20090310010508-rvs68o2223720rxn
loggerhead can now be installed as a plugin and run by 'bzr serve --http'

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
 
        pagesize = int(self._branch.config.get('pagesize', '20'))
37
 
 
38
 
        revid_list, start_revid = h.get_file_view(None, None)
39
 
        entries = list(h.get_changes(list(revid_list)[:pagesize]))
40
 
 
41
 
        vals = {
42
 
            'branch': self._branch,
 
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, path, kwargs, headers):
 
28
        history = self._history
 
29
        revid = self.get_revid()
 
30
        pagesize = int(20)#self._branch.config.get('pagesize', '20'))
 
31
 
 
32
        revid_list = history.get_file_view(history.last_revid, None)
 
33
        entries = list(history.get_changes(list(revid_list)[:pagesize]))
 
34
 
 
35
        headers['Content-Type'] = 'application/atom+xml'
 
36
        return {
43
37
            'changes': entries,
44
 
            'util': util,
45
 
            'history': h,
46
38
            'updated': entries[0].date.isoformat() + 'Z',
 
39
            'history': self._history,
47
40
        }
48
 
        h.flush_cache()
49
 
        return vals