[Zope3-Users] Re: Autocreated content objects

Tom Dossis td at yoma.com.au
Mon Sep 25 20:18:13 EDT 2006


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())

> 
> On Mon, 25 Sep 2006 18:55:11 +0200, Volker Bachschneider wrote
>> Philipp von Weitershausen schrieb:
>>> John Maddison wrote:
>>>> Is it possible/wise to "auto-create" content objects in the ZODB?  Say
>>> Yeah, like Stephan says, Zope should probably send an 
>>> IObjectCreatedEvent there. In the mean time, you can hook into
>> That works fine to me, but:
>>
>> import transaction
>> from zope.app.myproject.person import Person
>> from zope.event import notify
>> from zope.livecycleevent import ObjectCreatedEvent
>> obj = app.root()['005'] = Person()
>> obj.nnam = u'Karlson'
>> notify(ObjectCreatedEvent(obj))
>> transaction.commit()
>>
>> creates a perfect object with timestamp in the ZODB. But the IntId / 
>> Catalog do not recognizes the object. On the other hand, an object 
>> manual created via zmi and programatically modified via Script (with 
>> event ObjectModifiedEvent) is noticed and can be reindexed. Objects 
>> created only via zmi are recognizes and indexed. I think i have to 
>> fire up an IntIdAddedEvent but do not how.
>>
>> Volker
>> _______________________________________________
>> Zope3-users mailing list
>> Zope3-users at zope.org
>> http://mail.zope.org/mailman/listinfo/zope3-users
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 



More information about the Zope3-users mailing list