[Zope-CMF] wrong review_state DURING state transition

Encolpe DEGOUTE edegoute at nuxeo.com
Mon Mar 8 06:37:02 EST 2004


Dans local.lists.zope.zope-cmf Romain Slootmaekers écrivit:

| Yo,
| 
| I have a product installer that does various things, including 
| instantiating, copying, publishing some content items and updating the 
| portal catalog.
| 
| Some of the items are published in the installer using the following code:
| 
| workflows=plone.portal_workflow.getWorkflowsFor(o)
| workflow= workflows[0]
| 
| if o.isPrincipiaFolderish :
|      workflow.doActionFor(o, 'publish')
|      childIds=o.objectIds()
|      _publish(o,childIds,plone) #recurse...
| else:
|      workflow.doActionFor(o, 'publish')
| 
| 
| 
| This works fine.
| 
| The state transition triggers a reindexObject call on the object in 
| question, but if I try to access the review_state of that object inside 
| the reindexObject method, with following code snippet:
| 
| workflows = self.portal_workflow.getWorkflowsFor(self)
| workflow = workflows[0]
| state = workflow.getInfoFor(self, 'review_state','')
| 
| 
| it returns the old review state, and not 'published' .
| 
| Using a more direct approach with:
| workflow_history['plone_workflow'][-1]['review_state']
| 
| 
| does not help.
| 
| Googling for a solution, I found
| http://www.mmmanager.org/collectors/cmf_article/18
| 
| But the content type class has following inheritence signature:
| 
| class MyType (PortalContent, DefaultDublinCoreImpl ):
|      """
| 
|      """
|      __implements__ = ( PortalContent.__implements__,
|                         DefaultDublinCoreImpl.__implements__
|                       )
| 
|      ...
| 
| 
| So it inherits from CMFCatalogAware via 
| PortalContent(DynamicType,CMFCatalogAware,SimpleItem) first
| 
| (Changing the inheritence order does not change the behavior... I tried)
| 
| 
| 
| So, my questions:
| - is this a bug, a feature, or am I trying to access the review state in 
|    the wrong way ?
| 
| - is there another method called after a state change more suited for 
| installing my "state change push -through to something else", than 
| reindexObject ? I tried "notifyModified", buth that doesn't get called 
| on every state change, so it seems.
| 
| For the record: this is CMF 1.3.2 and plone 1.0.5

In the default workflow of DCWorkflow it using the state_change.object
during the teransition to get the object in the new state before the 
commit of the transaction.
There's some details in DCWorkflow/doc and DCWorkflow/help directories.

Regards,
-- 
Encolpe DEGOUTE, Ingenieur Logiciel, Nuxeo SARL: Zope Service Provider.
Mail: edegoute at nuxeo.com - Tel: +33 (0)1 40 33 79 18
Nuxeo Collaborative Portal Server: http://www.nuxeo.com/cps
Gestion de contenu web / portail collaboratif / groupware / open source



More information about the Zope-CMF mailing list