[Zope3-dev] [SOLVED]:  workflow and python-created objects

Markus Leist ml_zope3_dev at ikom-online.de
Tue Feb 8 05:19:12 EST 2005


[SOLVED]: 

Sorry, it's "long" ago ....
for solution see down below.


18.01.2005 08:37; Markus Leist:
> Hello,
>
> i wasn't able to find any information in docu or mailing-list for this
> problem:
>
> after working through the tutorial i'm able to create an object
> in ZMI. This object has a workflow definition and ZMI displays
> various states of transitions - seems to be really fine.
>
> When Zope (from cvs) creates an equal object by:
>                 newHost = removeAllProxies(
>                     zapi.createObject(None, 'ikom.ikhost.IkHost'))
> or
>                 newHost = zapi.createObject(None, 'ikom.ikhost.IkHost')
> all attributes und methods works well but workflows.html will be empty.
>
> isn't createObject an other kind of creation which will look for
> workflow-manager and automaticly add the process-definition
> to my instance.
>
> Is there a problem in my understanding?
>
> Where is other documentation or examples in python-generated
> objects and workflow.
>
> Please help
>

Solutions:
> On Tuesday 18 January 2005 02:37, Markus Leist wrote:
> > isn't createObject an other kind of creation which will look for
> > workflow-manager and automaticly add the process-definition
> > to my instance.
> >
> > Is there a problem in my understanding?
>
> Yes.
>
> Workflow instances are added to a content object by the workflow manager.
> The workflow manager is a event subscriber to `IObjectCreatedEvent`s.
> `createObject()` does not generate such an event and thus no workflow
> instances are added. When adding objects programmatically, you need to do
>
> something like:
> >>> from zope.app...? import objectevent
> >>> from zope.event import notify
> >>> event = objectevent.ObjectCreatedEvent(object)
> >>> notify(event)
> >
> > Where is other documentation or examples in python-generated
> > objects and workflow.
>
> There is no other documentation.
>
> Regards,
> Stephan


> Hi Markus,
> The content workflow uses an event subscriber for its post-creation
> handling. An IObjectCreatedEvent causes workflow instances to be added
> to content objects when they are created. Therefore you may have to
> invoke this handler notifying an IObjectCreatedEvent explicitely.
>
> from zope.app.event.objectevent import ObjecCreatedEvent
> from zope.event import notify
>
> newHost = zapi.createObject(None, 'ikom.ikhost.IkHost')
> notify(ObjectCreatedEvent(newHost))
>
> Within the container framework, this job is done regularly by the adding
> views.
>
> Regards,
> Dominik Huber
>
> Projekt01 GmbH
> _____________________________
> END OF MESSAGE

thanks for helping,

Markus


More information about the Zope3-dev mailing list