>> The correct code should probably be this:
>>
>> def load_sqla(handler):
>> web.ctx.orm = scoped_session(sessionmaker(bind=engine))
>> try:
>> return handler()
>> except web.HTTPError:
>> web.ctx.orm.commit()
>> raise
>> except:
>> web.ctx.orm.rollback()
>> raise
>> else:
>> web.ctx.orm.commit()
Looks like that doesn't work either. else-part is not called because
of the return. Here is the fix (not tested though..)
def load_sqla(handler):
web.ctx.orm = scoped_session(sessionmaker(bind=engine))
try:
result = handler()
except web.HTTPError:
web.ctx.orm.commit()
raise
except:
web.ctx.orm.rollback()
raise
else:
web.ctx.orm.commit()
return result
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---