Am Donnerstag, 1. Februar 2007 13:41 schrieb Alek Kowalczyk:
Hi,
I need to trigger periodically activities on various local components (i.e
stored in ZoDB). I found zope.scheduler package which seem to be nice
cron-like tool for Zope. But I did not find a clue how to use it with local
components - in examples it is registered as global utility.
I think about few ways of doing that. Please advice which one is the
correct one: a) make zope.scheduler call via xml-rpc some URLs to trigger
the activities
b) find (how?) local objects from scheduler global utility
and trigger activities c) register scheduler as local utility - it seems to
be impossible for me, as it rather cannot be persistent, can it?
You can open a connection to the database and use it this way. Here is an
example code that works but generated an error ofter some calls:
db = getUtility(ZODB.interfaces.IDatabase)
conn = db.open()
root = conn.root().data['Application']
zope.app.component.hooks.setSite(root)
utils = getUtilitiesFor(IYourInterface)
for i in utils:
print Utility found:, i[0]
db.close()
but after some calls it gives an error:
exceptions.ValueError: I/O operation on closed file
Don't know why.
d) other solution?
The solution b) is the one I feel is the right one. But how to find local
objects? Can I hook into DatabaseOpenedWithRoot event and pass the database
reference to global utility? If yes - how to deal with transactions...?
Regards,
Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users