~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/atom_ui.py

  • Committer: Robey Pointer
  • Date: 2007-01-02 07:17:25 UTC
  • Revision ID: robey@lag.net-20070102071725-nreem2cu8aiu4vsb
add the ability to auto-publish anything found under a particular folder.

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
20
22
 
21
23
from loggerhead import util
22
 
from loggerhead.templatefunctions import templatefunctions
23
 
 
24
 
from turbosimpletal import TurboZpt
25
 
 
26
 
t = TurboZpt()
27
 
tt = t.load_template('loggerhead.templates.atom')
28
24
 
29
25
 
30
26
class AtomUI (object):
31
 
 
 
27
    
32
28
    def __init__(self, branch):
33
29
        # BranchView object
34
30
        self._branch = branch
35
31
        self.log = branch.log
36
32
 
37
 
    def default(self, response, request):
38
 
        h = self._branch.history
39
 
 
40
 
        h._branch.lock_read()
41
 
        try:
42
 
            pagesize = int(20)#self._branch.config.get('pagesize', '20'))
43
 
 
44
 
            revid_list = h.get_file_view(h.last_revid, None)
45
 
            entries = list(h.get_changes(list(revid_list)[:pagesize]))
46
 
 
47
 
            vals = {
48
 
                'branch': self._branch,
49
 
                'changes': entries,
50
 
                'util': util,
51
 
                'history': h,
52
 
                'updated': entries[0].date.isoformat() + 'Z',
53
 
            }
54
 
            vals.update(templatefunctions)
55
 
            response.headers['Content-Type'] = 'application/atom+xml'
56
 
            tt.expand_(response, **vals)
57
 
        finally:
58
 
            h._branch.unlock()
 
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
            'external_url': cherrypy.request.base,
 
43
            'branch': self._branch,
 
44
            'changes': entries,
 
45
            'util': util,
 
46
            'history': h,
 
47
            'scan_url': '/changes',
 
48
            'updated': entries[0].date.isoformat() + 'Z',
 
49
        }
 
50
        h.flush_cache()
 
51
        return vals