Also, about the wiki tutorial... I have a suggestion about the part on
clicking links to non-existing pages.

Instead of carying that magic "new" flag everywhere in edit.kid and in
the "save" method... the edit and save methods might reuse the try:
except SQLObjectNotFound: pattern already learned in the index method.

Like so:


    def save(self, pagename, data, **kwds):
        hub.begin()
        try:
            page = Page.byPagename(pagename)
            page.data = data
        except SQLObjectNotFound:
            page = Page(pagename=pagename, data=data)
        hub.commit()
        hub.end()
        turbogears.flash("Changes saved!")
        raise cherrypy.HTTPRedirect("/%s" % pagename)

    def edit(self, pagename):
        try:
            page = Page.byPagename(pagename)
        except SQLObjectNotFound:
            return dict(pagename=pagename, data="")
        return dict(pagename=page.pagename, data=page.data)

the notfound method will not be needed, less code, and no magic flags
in the templates.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to