On 26/02/2011 09:09, Romy wrote:
It sounds like a better approach would be to wrap each request
handler's code as follows:

try:
   RequestHandler()
   elixir.session.commit()
except:
   elixir.session.rollback()
   raise
finally:
   elixir.session.remove()

Q1: Is this, in fact, the better approach ?

Yep, that looks about right.

Q2: If so, I already have a whole bunch of RequestHandlers written, so
the only way I can think of making this change efficiently is by
modifying Tornado's internals, which I'd prefer not to do.

Does Tornado do wsgi?

Are there
other options ? I guess with_session type decorators are on the table
as well, but will be pretty repetitive since all the handlers need
sessions.

Do your RequestHandler's share a common base?
Sounds like they should, and that base's __call__ method should to the try/except/finally above.

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
           - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to