-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Description
At the start of every Cheetah method, if there's no running transaction, Cheetah will create a dummy one and assign it to self.transaction. At the end of the method, if self.transaction is a dummy, Cheetah will set it back to None.
All is well and good, unless the method happens to use #return
, in which case the cleanup code never runs. The cleanup should be in a finally block, instead.
Upshot of this problem:
#def foo():#return "hello"
#def bar():world
>>> tmpl.foo()
'hello'
>>> tmpl.bar()
<object object at 0x7f96764a40a0>
That anonymous object is actually the NO_CONTENT
sentinel that Cheetah returns when it thinks it's being called within a transaction.
The fix is to clean up the transaction in a finally block.