CherryPy Project Download

Instead of doing a commit on every query in every action you can allow the request handler to do the commit for you. This is very similar to the Dejavu example shown in the tools section as well. This basically attempts to do a commit and if it doesn't commit it does a rollback and spits out an error.

def do_commit():
		cherrypy.log(format_exc(), "STORM")

def try_commit():
		cherrypy.request.hooks.attach('on_end_request', do_commit)
		if isinstance(cherrypy.response.body, types.GeneratorType):
		do_commit() = cherrypy.Tool('on_end_resource', try_commit)

Simply create the tool and then in your config you need to have

tools.storm.on = True

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages