On Tue, Apr 10, 2007 at 10:19:43PM -0700, Tim Nash wrote:
Does anybody have a script available that shows how to insert objects into the ZODB root['Application'] from a non-zope process outside the Zope application? Everytime I try to read root['Application'] I get a page template error.
I'm using zope 2.5 (matches a book I like)
You can do whatever you like, but you're not likely to find many people still running 2.5 on this list... so you might get less useful help than you would like.
and doing like so:
from ZODB import FileStorage, DB storage = FileStorage.FileStorage('Data.fs') db = DB(storage) connection = db.open() root = connection.root()
Also, can the ZODB be altered this way on a running Zope instance?
Not with FileStorage. Only one process at a time can open a FileStorage. If you would use ZEO instead, then it would be possible. Your code above would then be modified to use ClientStorage instead of FileStorage. But I don't know exactly what the code would look like in zope 2.5, I haven't run that version in years. I vaguely remember needing a custom_zodb.py file to set up ClientStorage. If you would upgrade to a more recent Zope (2.7 or later), then ZEO is available out of the box just by uncommenting some lines in the example zope.conf. And you would also get a script at bin/zopectl that's perfect for this kind of job. Your own script would be invoked as an argument to zopectl, like: ./bin/zopectl run path/to/my/script ... and you would get the root application automatically set up for you and bound as "app". But you still need to use ZEO. -- Paul Winkler http://www.slinkp.com