[Zope-dev] unpickleable error

Michel Pelletier michel@digicool.com
Wed, 08 Mar 2000 10:30:11 -0800


Toby Dickenson wrote:
> 
> On Tue, 07 Mar 2000 02:53:45 -0800, Michel Pelletier
> 
> >> want the file converted). All my dtml method does is change data in a few
> >> already-defined properties. I've commented out my dtml statements and put
> >> them back in one at a time, to see if I can isolate the one which is causing
> >> the error. Here it  is:
> >>
> >> <dtml-call "manage_changeProperties(upload_file=REQUEST['new_file'],)">
> >>
> >> "new_file" is the name of an input field of type "file" in the form the
> >> dtml method containing the line above was called from. If i replace the
> >> line above with the following:
> >>
> >> <dtml-call "manage_changeProperties(upload_file='This is a test',)">
> >>
> >> things work fine.
> >
> >what gets assigned to 'upload_file' is probably not pickleable.  What
> >that is I don't know, you will have to find out what kind of object is
> >getting assigned or is trying to store itself as a property.  This is
> >just a guess, there is not enough information to pin it down exactly.
> 
> Ive run into this several times, and you've prompted me to look into
> why.
> 
> I think manage_changeProperties and manage_editProperties should be
> using self._updateProperty rather than self._setPropValue.
> 
> self._updateProperty performs type checking on the property values. In
> this case you property would probably get the value
> <file object at 0x12345678>

Ah, you are correct!  Python file objects are not pickleable (for
everyone's sake, this is not the same kind of file objects as Zope File
Objects, but rather the python kind).  For the sake of correctness, the
code should be:

<dtml-call
"manage_changeProperties(upload_file=REQUEST['new_file'].read())">

As for the case of changing PropertyManager we'll have to think about
that (so yes, please file it in the collector).

-Michel