/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Martin Albisetti
  • Date: 2008-06-20 17:28:20 UTC
  • mfrom: (164 trunk)
  • mto: (157.1.3 loggerhead)
  • mto: This revision was merged to the branch mainline in revision 187.
  • Revision ID: argentina@gmail.com-20080620172820-tbf0ewc7qhpsghxb
Merge from trunk!  Yay!

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
 
            return vals
54
 
        finally:
55
 
            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, response):
 
28
        h = self._branch.history
 
29
 
 
30
        pagesize = int(20)#self._branch.config.get('pagesize', '20'))
 
31
 
 
32
        revid_list = h.get_file_view(h.last_revid, None)
 
33
        entries = list(h.get_changes(list(revid_list)[:pagesize]))
 
34
 
 
35
        response.headers['Content-Type'] = 'application/atom+xml'
 
36
        return {
 
37
            'changes': entries,
 
38
            'updated': entries[0].date.isoformat() + 'Z',
 
39
        }