[Erp5-dev] storing binary data in content objects

Jérome Perrin jerome at nexedi.com
Fri Nov 23 17:05:05 CET 2007


bartek a écrit :
> Hello
> 
> I tried to use the content storage mechanism - the one that works so 
> nicely for email, phone number, career etc - to store a picture (e.g. an 
> image of a person). Tried to define a property normally:
> 
>          { 'id'                       : 'picture'
>          , 'storage_id'               : 'default_picture'
>          , 'description'              : 'The current picture of the person'
>          , 'type'                     : 'content'
>          , 'portal_type'              : ( 'Image', )
>          , 'acquired_property_id'     : ( 'file', 'data')
>          , 'mode'                     : 'w'
>          },
> 
> and added a FileField named "my_picture_file" or 
> "my_default_picture_file" to a Person_view form.
> 
> But it doesn't work as expected - when I upload a file to a Person 
> object, the system creates an Image object named "default_picture" but 
> the "data" attribute of the Image contains file name instead of data.
> 
> And I'm confused - I thought that ERP5 would create a content object and 
> just pass on what it received to the object's setter method, but 
> apparently it does something else in the meantime. Any hint?

Hello,

You should use ERP5/PropertySheet/DefaultImage.py
I think what's missing is this line:
       'acquisition_accessor_id'   : 'getDefaultImageValue',

Jérome






More information about the Erp5-dev mailing list