Porting user sync code from 2.1.3, get Error in PAS code getUtility()

Wichert Akkerman wichert at wiggy.net
Fri Oct 26 07:10:23 UTC 2007


Previously jgayle wrote:
> 
> 
> jgayle wrote:
> > 
> > The original code is run from a .zctl script scheduled with cron.
> > 
> 
> Ok, so from the #plone irc I was informed that a publishTranversal is not
> executed from zctl scripts. 

As the name implies publish traversal is only done during publication.
That is something quite different than running a script from the command
line.

> I assumed this was done with a call to
> unrestrictedTraversal('site_root') but I guess not.


Indeed. That is normal traversal, not publication traversal. Publication
traversal is done by the ZPublisher or zope.publisher, normally via a
BeforeTraverseEvent event.

> So now the question is how to you initiate a publishTraversal in a
> zctl script such that a local site manager is set?

You do not need to initiate publish traversal. What you need is to set
the correct local site manager. During publication that happens
automatically. In other cases you need to do that by hand.

> I have looked for hours and can't seem to piece this together. Is this even
> possible with Plone 3?

It is quite simple:

    from zope.app.component.hooks import setSite
    portal=app.Plone
    setSite(plone)

Wichert.

-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.




More information about the Product-Developers mailing list