Wichert Akkerman wrote:
Previously yuppie wrote:
Here are my assertions:
a) The right place for calling notifyWorkflowCreated() and indexObject()
is the event handler for IObjectAddedEvent. _setObject() sends this
event by default.
b) Oldstyle factory methods are not responsible for setting the portal
type. They call _setObject() to early for sending IObjectAddedEvent
because the portal type might be wrong at that moment.
1.) Let's get rid of _finishConstruction(): Using newstyle factories we
should set the portal type *before* calling _setObject().
notifyWorkflowCreated() and reindexObject() should be called by the
2.) Fix *all* oldstyle factories: They don't finish content creation, so
they should not send the events. Since ScriptableTypeInformation factory
methods don't call _setObject() directly, this affects only file system
Has to be replaced by:
self._setObject(id, o, suppress_events=True)
In each factory of each third party content type. I don't like that, but
it is the only solution I see that allows us to use the events correctly.
3.) For oldstyle factories, set the portal type after calling the
factory and send events after that. Unfortunately We can't send the
IObjectWillBeAddedEvent because we don't know the object before it is added.
4.) For newstyle factories, also set the portal type, but let
_setObject() send the events.
5.) Modify handleContentishEvent(): Add the notifyWorkflowCreated() call
for IObjectAddedEvent. indexObject() is already called.
Any comments? Questions? Objections?
This change broke Plone: Plone has a routine that constructs new content
objects while bypassing parts of CMF which now breaks when it tries to
There is no BBB code because _finishConstruction is an internal
If we agree that factory methods should not send events this change is
not sufficient: http://dev.plone.org/plone/changeset/18899
1.) suppress_events=True has to be used in oldstyle factories
2.) your code has to send the IObjectAddedEvent as well
If you think that change needs better documentation or BBB code, please
let me know.
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests