Mercurial > genshi > genshi-test
comparison examples/tutorial/geddit/controller.py @ 627:2f4dc32a13e7
GenshiTutorial: minor tweaks to sync with Wiki page.
author | cmlenz |
---|---|
date | Fri, 31 Aug 2007 23:13:27 +0000 |
parents | dba522b4c31d |
children | 693a7212b348 |
comparison
equal
deleted
inserted
replaced
626:3110105824e8 | 627:2f4dc32a13e7 |
---|---|
36 def index(self): | 36 def index(self): |
37 links = sorted(self.data.values(), key=operator.attrgetter('time')) | 37 links = sorted(self.data.values(), key=operator.attrgetter('time')) |
38 return template.render(links=links) | 38 return template.render(links=links) |
39 | 39 |
40 @cherrypy.expose | 40 @cherrypy.expose |
41 @template.output('info.html') | |
42 def info(self, id): | |
43 link = self.data.get(id) | |
44 if not link: | |
45 raise cherrypy.NotFound() | |
46 return template.render(link=link) | |
47 | |
48 @cherrypy.expose | |
49 @template.output('submit.html') | 41 @template.output('submit.html') |
50 def submit(self, cancel=False, **data): | 42 def submit(self, cancel=False, **data): |
51 if cherrypy.request.method == 'POST': | 43 if cherrypy.request.method == 'POST': |
52 if cancel: | 44 if cancel: |
53 raise cherrypy.HTTPRedirect('/') | 45 raise cherrypy.HTTPRedirect('/') |
61 errors = e.unpack_errors() | 53 errors = e.unpack_errors() |
62 else: | 54 else: |
63 errors = {} | 55 errors = {} |
64 | 56 |
65 return template.render(errors=errors) | HTMLFormFiller(data=data) | 57 return template.render(errors=errors) | HTMLFormFiller(data=data) |
58 | |
59 @cherrypy.expose | |
60 @template.output('info.html') | |
61 def info(self, id): | |
62 link = self.data.get(id) | |
63 if not link: | |
64 raise cherrypy.NotFound() | |
65 return template.render(link=link) | |
66 | 66 |
67 @cherrypy.expose | 67 @cherrypy.expose |
68 @template.output('comment.html') | 68 @template.output('comment.html') |
69 def comment(self, id, cancel=False, **data): | 69 def comment(self, id, cancel=False, **data): |
70 link = self.data.get(id) | 70 link = self.data.get(id) |