diff examples/tutorial/geddit/controller.py @ 622:6780f1b1b20d trunk

GenshiTutorial: add Atom feeds.
author cmlenz
date Thu, 30 Aug 2007 22:49:48 +0000
parents 756e7418e10c
children abad7c2ebe15
line wrap: on
line diff
--- a/examples/tutorial/geddit/controller.py
+++ b/examples/tutorial/geddit/controller.py
@@ -20,6 +20,18 @@
         self.data = data
 
     @cherrypy.expose
+    @template.output('index.xml', method='xml')
+    def feed(self, id=None):
+        if id:
+            link = self.data.get(id)
+            if not link:
+                raise cherrypy.NotFound()
+            return template.render('info.xml', link=link)
+        else:
+            links = sorted(self.data.values(), key=operator.attrgetter('time'))
+            return template.render(links=links)
+
+    @cherrypy.expose
     @template.output('index.html')
     def index(self):
         links = sorted(self.data.values(), key=operator.attrgetter('time'))
@@ -27,8 +39,8 @@
 
     @cherrypy.expose
     @template.output('info.html')
-    def info(self, code):
-        link = self.data.get(code)
+    def info(self, id):
+        link = self.data.get(id)
         if not link:
             raise cherrypy.NotFound()
         return template.render(link=link)
@@ -54,8 +66,8 @@
 
     @cherrypy.expose
     @template.output('comment.html')
-    def comment(self, code, cancel=False, **data):
-        link = self.data.get(code)
+    def comment(self, id, cancel=False, **data):
+        link = self.data.get(id)
         if not link:
             raise cherrypy.NotFound()
         if cherrypy.request.method == 'POST':
Copyright (C) 2012-2017 Edgewall Software