[ZODB-Dev] afterCommitHook
Victor Safronovich
vsafronovich at naumen.ru
Wed Sep 21 07:19:07 EDT 2005
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.
--
Best regards,
Victor Safronovich
NauMen.NauDoc.SoftwareDeveloper http://www.naumen.com
More information about the ZODB-Dev
mailing list