[Zope3-Users] ZODB - root and transaction

Andreas Reuleaux reuleaux at web.de
Wed Apr 5 08:31:16 EDT 2006


I can't really point at your problem, sorry.  But I have a similar
script to fill my ZODB which works for me. You might want to try to
experiment with this / modify your script ...

    #!/usr/bin/env python2.4
    # -*- coding: utf-8 -*-

    from ZODB import FileStorage, DB
    import transaction
    # ...
    fs = FileStorage.FileStorage('/home/reuleaux/z3/Data.fs')
    db = DB(fs)
    con=db.open()
    root = con.root()
    app=root['Application']
    bookfolder=app['bookfolder']
    # ...
    bookfolder[name]=b

    transaction.commit()
    db.close()


-Andreas


On Wed, Apr 05, 2006 at 10:33:55AM +0000, Reinhold Strobl wrote:
> Hi,
> 
> I have got two problems, which are related:
> 
> 1. How do get a reference to the root object of the ZODB everywhere?
> 
> I mean I have found a solution like something:
> 
>             db = zapi.getUtility(IDatabase)
>             conn = db.open()
>             root = conn.root()
>             root['123'] = newbook
> 
> But it does not acutally store the object in the database. 
> I try to commit it, but
> 
> conn.getTransaction.commit()
> 
> won't work. I search instead for get_transaction(), but I didn't found it in
> Python 's lib directory.
> 
> So, how do I save it???
> 
> 2. How do I get (the current) transaction?
> 
> Thanks a lot in advance! 
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 
> 
> !DSPAM:4433b55b83084275821350!


More information about the Zope3-users mailing list