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
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to