[Zope-CMF] Problem adding Portal Images programatically

Florent Guillaume fg@nuxeo.com
5 Oct 2001 12:33:20 GMT


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