diff options
Diffstat (limited to 'pecan/hooks.py')
-rw-r--r-- | pecan/hooks.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pecan/hooks.py b/pecan/hooks.py index 2795f95..e8848b7 100644 --- a/pecan/hooks.py +++ b/pecan/hooks.py @@ -160,10 +160,18 @@ class TransactionHook(PecanHook): self.rollback() else: self.commit() + + # + # If a controller was routed to, find any + # after_commit actions it may have registered, and perform + # them. + # controller = getattr(state, 'controller', None) - actions = _cfg(controller).get('after_commit', []) - for action in actions: - action() + if controller is not None: + actions = _cfg(controller).get('after_commit', []) + for action in actions: + action() + self.clear() class RequestViewerHook(PecanHook): |