[storm] Can't get zstorm working in my project
R Pish
rpishcr at gmail.com
Mon Mar 31 18:02:14 UTC 2014
Hi, I started using zstorm very recently and I was very interested on using
zstorm. After investigating, I was able to put some code and get it
working, but I am having an issue with registrating the store into the
transaction.
The following is my code:
from zope.component import provideUtility, getUtility
import transaction
from storm.zope.interfaces import IZStorm
from storm.zope.zstorm import global_zstorm
provideUtility(global_zstorm, IZStorm)
zstorm = getUtility(IZStorm)
zstorm.set_default_uri("test", database_dsn) # database_dsn is a variable
that contains the mysql db dsn
store = zstorm.get("test")
store._event.emit("register-transaction")
# I look for a user in my users table in order to make an update
user = store.find(User, User.login == loginvar).one()
user.token = u"Some test token for now"
user.token_expires = session_timeout # assume that session_timeout is a
variable with a valid timestamp
transaction.commit()
My problem is that if I use transaction.commit(), then the record is not
updated in the database. But, if I use store.commit(), then the records
does get updated.
Why transaction.commit() is not working? Am I missing something?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/storm/attachments/20140331/4fc299dc/attachment.html>
More information about the storm
mailing list