Hi there,
I'm not able to get before/after commit hooks or synchronizers to work, hope someone here can explain what I'm doing wrong (or please point me at the relevant list). I'm following the tutorial here:
.. and got the PickleDataManager working. But when I add the before- and after-
commit hooks verbatim from the tutorial, I get the following error:
Traceback (most recent call last):
File "pickledm.py", line 145, in <module>
transaction.commit()
File "/Users/siddhartha/.virtualenvs/pyramid/lib/python2.7/site-packages/transaction/_manager.py", line 107, in commit
return self.get().commit()
File "/Users/siddhartha/.virtualenvs/pyramid/lib/python2.7/site-packages/transaction/_transaction.py", line 339, in commit
self._callBeforeCommitHooks()
File "/Users/siddhartha/.virtualenvs/pyramid/lib/python2.7/site-packages/transaction/_transaction.py", line 413, in _callBeforeCommitHooks
hook(*args, **kws)
TypeError: before_commit() got an unexpected keyword argument 'a'
When I pass in a blank dict instead of the {'a':1} from the tutorial, I get this error:
File "pickledm.py", line 17, in before_commit
for arg in args:
TypeError: 'int' object is not iterable
... and I find that, in fact, printing 'args' inside the hook function shows that it is equal to 1, and not the tuple (1,2) that was passed.
I also tried adding a
synchronizer, and initially got this error:
TypeError: unbound method beforeCompletion() must be called with synch instance as first argument (got Transaction instance instead)
It looked like this may have been due to a typo in the tutorial, I changed:
transaction.manager.registerSynch(sync)
to:
transaction.manager.registerSynch(sync())
...to pass an instance instead of a class and the error goes away. Unfortunately the synchronizer methods don't seem to be called when the transaction is executed, and I don't see the output from those functions.
Thanks,
-Sid