[Zope-CMF] Problem adding Portal Images programatically

Florent Guillaume fg@nuxeo.com
Fri, 5 Oct 2001 15:00:12 +0200


Jens,

Indeed, but manage_afterAdd is called at _setObject time, which happens
in the factory method (or script). portal_type is initialized just after
that.

Florent


In article <D47ACB4A-B98E-11D5-B700-003065C04F34@zope.com> you write:
> florent,
> 
> CMFCore.PortalContent has a call to indexObject inside manage_afterAdd, 
> this should get invoked unless you have special content that grabs a 
> different manage_afterAdd because of its inheritance hierarchy (i've come 
> up against that myself before).
> 
> jens
> 
> 
> 
> On Friday, October 5, 2001, at 12:33 , Florent Guillaume wrote:
> 
> > Speaking about invokeFactory, I wanted to mention a little bug:
> > constructInstance builds the object by calling the factory method (or
> > the script), then sets the portal_type using _setPortalTypeName. But it
> > never reindexes the object, which means that this portal_type is not
> > catalogged until the next object edition (usually). This is a problem
> > for me because I have a site where I do a lot of searches on
> > portal_type.
> >
> > Would a "ob.reindexObject()" at the end of constructContent be an
> > acceptable patch ?
> >
> >
> > 	Florent
> >
> >
> > Jens Vagelpohl  <jens@zope.com> wrote:
> >> if you use invokeFactory instead of addImage in your createImage method
> >> then the portal type gets set correctly as well as cataloging and 
> >> workflow
> >> stuff.
> >>
> >> check CMFCore/PortalFolder.py for details, it takes an argument 
> >> "type_name"
> >>   ('Image' in this case) and an id. then you grab a reference to this new
> >> image and set the image contents (the "file" argument) by using the 
> >> image'
> >> s edit method (see CMFDefault/Image.py)
> >>
> >> jens
-- 
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com