[Zope3-Users] Scheduler package usage

Tom Dossis td at yoma.com.au
Tue Nov 21 16:12:45 EST 2006

Thierry Florac wrote:
> But now I have to face another problem : tasks are executed outside of
> any request or context environment ; because of this, components lookups
> always fail !
> So I'd like to know :
>  - how can I handle transactions ?

I expect the normal explicit transaction calls to work, but not that
I've used the scheduler myself:

  import transaction

>  - how can I "simulate" a real request, so that components lookups work
> correctly ?

Do you need to lookup up views?  I guess using a TestRequest() (or an
I*Request implementing object would do.

>  - as I use virtual hosting, my utilities are located and registered in
> a "sub-site". How can I get access to these components in my scheduler
> tasks throught zapi functions, without knowing "a priori" their names or
> paths ?

from zope.app.component import hooks

This should make your utility lookups work.  Of course you still need a
way to get your subsite 'mysite' object, whether you traverse from the
root object, etc. is up to you.

Finally, I'm not sure if you need to setup an interaction, which raises
the question: what/who is the principal in within your scheduler context?


> Thanks,
>   Thierry Florac

More information about the Zope3-users mailing list