Hi,

Am Sonntag, den 21.01.2007, 14:44 +0100 schrieb Florian Lindner:
> Hello,
> I am in a function that has no context and want to set a site.
> The function is called periodically from a scheduler:
> 
> from scheduler import loop
> 
> def onStartup(event):
>     refresher = loop.LoopTask(releaseRefreshEvent, interval=60)
> 
> In this function I need to call getUtilitiesFor which needs a site set but I 
> don't know how to get a site:
> 
> (Pdb)  from zope.app.component import hooks
> (Pdb) from zope.app.zapi import *
> 
> (Pdb) hooks.setSite(getSiteManager())
> *** AttributeError: 'BaseGlobalComponents' object has no 
> attribute 'getSiteManager'
> 
> (Pdb) hooks.setSite(getGlobalSiteManager())
> *** AttributeError: 'BaseGlobalComponents' object has no 
> attribute 'getSiteManager'

You don't set the site managers as a site, but the objects that are
sites have site managers (or "component registries") attached to them.

Also, the global registry is always "active", without settinga site.

> Just getting the root object (which AFAIK always is a site) would be ok. Or 
> the object of static path.

You'd have to open a connection to the database, get the root object and
use that with setSite(). I don't have the complete spelling for that in
my head though. If this is code that runs within Zope 3, then you might
not want to talk to the database directly anyway because of the
automatic transaction management.

Christian

-- 
gocept gmbh & co. kg - forsterstra├če 29 - 06112 halle/saale - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to