Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Simplify the zope event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodbare committed Nov 27, 2016
1 parent cf93db6 commit 41864c8
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/plone.server/plone/server/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ async def _acallBeforeCommitHooks(self):
# add additional hooks while hooks are running, and iterating over a
# growing list is well-defined in Python.
for hook, args, kws in self._before_commit:
if asyncio.iscoroutinefunction(hook):
await hook(*args, **kws)
else:
hook(*args, **kws)
await hook(*args, **kws)
self._before_commit = []


Expand All @@ -116,17 +113,13 @@ async def _acallAfterCommitHooks(self, status=True):
# The first argument passed to the hook is a Boolean value,
# true if the commit succeeded, or false if the commit aborted.
try:
if asyncio.iscoroutinefunction(hook):
await hook(status, *args, **kws)
elif asyncio.iscoroutine(hook):
await hook(status, *args, **kws)
else:
hook(status, *args, **kws)
await hook(status, *args, **kws)
except:
# We need to catch the exceptions if we want all hooks
# to be called
self.log.error("Error in after commit hook exec in %s ",
hook, exc_info=sys.exc_info())

# The transaction is already committed. It must not have
# further effects after the commit.
for rm in self._resources:
Expand Down

0 comments on commit 41864c8

Please sign in to comment.