Skip to content

Sometimes junk is left in the transaction when #returning #143

@asottile

Description

@asottile

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions