[Zope-CMF] A 'Portal Image' added programaticaly behaves
 different than a manualy added one
   
    Grégoire Weber
     
    gregoire.weber@switzerland.org
       
    Fri, 03 Aug 2001 01:40:50 +0200
    
    
  
Thanks for your advice, Tres!
You took me to the right way. It even worked after changing a 
small detail...
I had to set 'portal_type' to 'Image' instead of setting it to 
'Portal Image'! That's it!
Zope's XML exporting functionality is cool! I came behind this 
by adding an additional image manualy and exporting both in 
XML to search for differences. :-)
> You need to get the 'portal_type' label of your image set, as
> the stock 'invokeFactory' mechanism does.
>
> Add this::
> 
>      image = f._getOb( 'org_logo' )
>      image.portal_type = 'Portal Image' # the ID of the type object
You're talking about the similar code parts in 'constructInstance' in 
TypesTool.py I suppose.
So I finaly use the following working code to instanate a Portal 
Image which seems to me to be "more compatible" (just for the 
archive searchers on the list)::
    # Create default logo.
    fileobj = open(os.path.join(product_path, 'img', 'earthsmile.gif'), 'rb')
    filedata = fileobj.read()
    Image.addImage(f,
                   'org_logo',
                   title = '%s Home' % member_id,
                   file = filedata,
                   format = 'image/gif')
    ob = f._getOb( 'org_logo' )
    if hasattr(ob, '_setPortalTypeName'):
        ob._setPortalTypeName('Image')
    fileobj.close()
Remaining question (answer mandatory):
   Why is this not necessary for the instanation of the 'index_html' 
   Document in 'createMemberarea' of 'CMFDefault/MembershipTool.py'?
   Shouldn't this be changed?
Greg
_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org