[Zope3-Users] Re: Autocreated content objects
Philipp von Weitershausen
philipp at weitershausen.de
Tue Sep 26 00:27:07 EDT 2006
Tom Dossis wrote:
> mats.nordgren wrote:
>> The IntId subscribers are fired on
>> zope.app.container.interfaces.IObjectAddedEvent and IObjectRemovedEvent.
>>
>
> That's correct, however the (IWrite)Container __setitem__ method invokes
> the ObjectAddedEvent for you when you add an object to the container.
>
> Your code below looks like it's running zope directly, e.g. `zopectl
> debug`. In this case you need to explicitly set a/the current site
> yourself. Try insert the following first up...
>
> from zope.app.component import hooks
> hooks.setSite(app.root())
Correct. SItes are usually found during traversal. When doing stuff
before any traversal is happening, you won't have a local site yet. So,
using setSite() is appropriate, just remember to call setSite(None)
afterwards for cleanup!
More information about the Zope3-users
mailing list