[Erp5-dev] storing binary data in content objects
bartek
bartek at erp5.pl
Sat Nov 24 15:48:44 CET 2007
Jérome Perrin wrote:
> 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',
>
What was really missing, was some grey cells in my brain :) I forgot to
set form encoding to multipart...
B.
> Jérome
>
>
>
> _______________________________________________
> Erp5-dev mailing list
> Erp5-dev at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-dev
>
--
"feelings affect productivity. (...) unhappy people write worse
software, and less of it."
Karl Fogel, "Producing Open Source Software"
More information about the Erp5-dev
mailing list