~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Martin Albisetti
  • Date: 2008-09-01 21:47:21 UTC
  • mfrom: (215.1.6 1.6.1)
  • Revision ID: argentina@gmail.com-20080901214721-cdlcjue6ggr6y86q
Tags: loggerhead-1.6.1
* Added --port, --host and --prefix options to serve-branches
* Fixed broken template for project browsing with start-loggerhead

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 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
 
            h.flush_cache()
54
 
            return vals
55
 
        finally:
56
 
            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
        }