[ZODB-Dev] afterCommitHook

Chris Withers chris at simplistix.co.uk
Fri Sep 23 11:12:19 EDT 2005


Why not just use MaildropHost?

Chris

Victor Safronovich wrote:
> Hello zodb-dev!
> 
> I   used  a  MailHost  product  for  e-mail notifications, but it sends mails at
> runtime. And when there are errors in transaction, objects have been created and its not
> commited, but users received mails.
> 
> I  think i must use an after commit hook, but transactions not supported such
> hooks.
> 
> I   write  the  basic class for after commit hook ( and I solved my problem with
> e-mails using it )
> 
> class AfterCommitHook(object):
> 
>     def __init__(self):
>         transaction.get().register(self)
> 
>     #######################################################
>     # ZODB Transaction hooks
>     #######################################################
> 
>     def commit(self, o, t):
>         pass
> 
>     def tpc_begin(self, t): 
>         pass
> 
>     def tpc_abort(self, t): 
>         pass
> 
>     def abort(self, o, t):
>         self.onAbort()
> 
>     def tpc_vote(self, t):
>         pass
> 
>     def tpc_finish(self, t):
>         self.onCommit()
> 
>     def sortKey(self):
>         return 1
> 
>     def onAbort(self):
>         raise NotImplementedError
> 
>     def onCommit(self):
>         raise NotImplementedError
> 
> But  it  should  be  better  to  add  addAfterCommitHook  to  transaction  as in
> addBeforeCommitHook.
> 

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the ZODB-Dev mailing list