[storm] Can't get zstorm working in my project

Oscar Campos oscar.campos at member.fsf.org
Mon Mar 31 22:06:27 UTC 2014


Hi.

Can I ask why you call the emit(‘register-transaction’) in your store object?

-- 
Join the free software foundation and become free as in freedom

On 31 March 2014 at 19:02:37, R Pish (rpishcr at gmail.com) wrote:

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.
--  
storm mailing list  
storm at lists.canonical.com  
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/storm/attachments/20140331/d649d0a3/attachment.html>


More information about the storm mailing list