# HG changeset patch # User cmlenz # Date 1188849543 0 # Node ID 693a7212b348f33ee070297bb3ca05611e113138 # Parent 2f4dc32a13e7d73e39fa9966ab3655b452909c13 GenshiTutorial: tweaks to sync with code on wiki page. diff --git a/examples/tutorial/geddit/controller.py b/examples/tutorial/geddit/controller.py --- a/examples/tutorial/geddit/controller.py +++ b/examples/tutorial/geddit/controller.py @@ -1,9 +1,6 @@ #!/usr/bin/env python -import operator -import os -import pickle -import sys +import operator, os, pickle, sys import cherrypy from formencode import Invalid @@ -20,18 +17,6 @@ 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')) @@ -92,6 +77,18 @@ stream = template.render(link=link, comment=None, errors=errors) return stream | HTMLFormFiller(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) + def main(filename): # load data from the pickle file, or initialize it to an empty list @@ -113,7 +110,7 @@ fileobj.close() cherrypy.engine.on_stop_engine_list.append(_save_data) - # Some global configuration; note that this could be moved into a + # Some global configuration; note that this could be moved into a # configuration file cherrypy.config.update({ 'request.throw_errors': True, diff --git a/examples/tutorial/geddit/templates/index.html b/examples/tutorial/geddit/templates/index.html --- a/examples/tutorial/geddit/templates/index.html +++ b/examples/tutorial/geddit/templates/index.html @@ -5,17 +5,24 @@ News +

News

-
    + -

    Submit new link

    +

    Submit new link

    diff --git a/examples/tutorial/geddit/templates/index.xml b/examples/tutorial/geddit/templates/index.xml --- a/examples/tutorial/geddit/templates/index.xml +++ b/examples/tutorial/geddit/templates/index.xml @@ -2,7 +2,7 @@ - Geddit + Geddit News diff --git a/examples/tutorial/geddit/templates/info.html b/examples/tutorial/geddit/templates/info.html --- a/examples/tutorial/geddit/templates/info.html +++ b/examples/tutorial/geddit/templates/info.html @@ -5,8 +5,8 @@ ${link.title} - +