[Zope3-Users] Calling utitlity without context
Florian Lindner
mailinglists at xgm.de
Tue Apr 10 09:57:51 EDT 2007
Hello,
I have a function that is called every 60 seconds from zope.scheduler. Due to
that it does not have a context. However I need to call a utility. I use that
piece of code:
def releaseRefreshEvent():
""" Calls all utlities that have a INewsfeed interface registered. """
import pdb; pdb.set_trace()
print "releaseRefreshEvent!!"
db = getUtility(ZODB.interfaces.IDatabase)
conn = db.open()
root = conn.root().data['Application']
zope.app.component.hooks.setSite(root)
utils = getUtilitiesFor(INewsfeed)
for i in utils:
print "Utility called:", i[0]
i[1].sendNotification()
conn.close()
This works fine as long as the registered utility is in root site. As soon as
it is in another site it does not find the utility anymore.
How can I fix that?
Thanks,
Florian
More information about the Zope3-users
mailing list