[Zope-CMF] [RFC] Type mess and allowed_content_types

Luca Olivetti luca@wetron.es
Sat, 06 Jul 2002 01:24:51 +0200


Florent Guillaume wrote:

>>Hi, with this change did you solve the problem I had described at:
>>http://lists.zope.org/pipermail/zope-cmf/2002-May/012600.html

[....]

> The bug you describe has been fixed by Tres:
> 
> Now the insertion into the workflow, through wf.notifyCreated(), is
> done by the Types Tool after the object has been created, and *not* at
> manage_afterAdd time (it's also done from manage_afterClone when a
> copy is made).
> 
> Your problem should be solved, provided you construct you objects
> through invokeFactory or constructContent.

I don't think so :-(
I just looked at the cvs version and constructInstance in TypesTool.py 
is identical to the one I have been using. And CMFCatalogAware (whose 
manage_afterAdd method I call in my manage_afterAdd -- inherited through 
PortalContent) still calls indexObject(), so the sequence of events 
should be the same I have explained, unless the problem is in some other 
place and I didn't diagnose it correctly.
When exactly manage_afterAdd gets called?
i.e.:

     def constructInstance( self, container, id, *args, **kw ):
         """
         Build a "bare" instance of the appropriate type in
         'container', using 'id' as its id.  Return the URL
         of its "immediate" view (typically the metadata form).
         """
         # Get the factory method, performing a security check
         # in the process.
         m = self._getFactoryMethod(container, raise_exc=1)

         if m is None:
             raise Unauthorized, ('Cannot create %s' % self.getId())

         id = str(id)

         if getattr( m, 'isDocTemp', 0 ):
             args = ( m.aq_parent, self.REQUEST ) + args
             kw[ 'id' ] = id
         else:
             args = ( id, ) + args

         id = apply( m, args, kw ) or id  # allow factory to munge ID
1 -->here
         ob = container._getOb( id )
2 -->here
         if hasattr(ob, '_setPortalTypeName'):
             ob._setPortalTypeName(self.getId())

         wf = getToolByName(ob, 'portal_workflow', None)
         if wf is not None:
             wf.notifyCreated(ob)

         return ob

3 --> or after here?


Keep in mint that I have to explicitly call _setPortalTypeName in my 
manage_afterAdd (and doing so precluding its use as a base class for 
different portal types, not a problem now but I don't like it) in order 
to have it indexed in the catalog with the correct value, so that seems 
to indicate 1 o 2, not 3.


-- 
Luca Olivetti