[Zope3-Users] UnpickleableError when adding object with reference

john saponara john at saponara.net
Tue Jan 15 18:27:04 EST 2008


That works great, thank you Thierry


Thierry Florac wrote:
> Le mardi 15 janvier 2008 à 07:05 -0500, john saponara a écrit :
>> I add a Limoservice object, then inside that object add a Car; then I 
>> add a Driver (which contains a Car), and the AddForm offers a dropdown 
>> with '(no value)' and my Car object.  If I select the car from the 
>> dropdown I get an error:
>>
>> UnpickleableError: Cannot pickle <type 'zope.security._proxy._Proxy'> 
>> objects
>>
>> Whereas if I leave the dropdown at '(no value)', the error does not 
>> occur.  What am I doing wrong?  (See attached error.txt for full error.)
> 
> Hi, 
> As explained into error message, you can't store security proxied
> objects into ZODB : you have to remove proxy before they can be stored.
> 
> What I generally do is just something like this :
> 
>   ...
>   from zope.security.proxy import removeSecurityProxy
> 
>   class Driver(Contained):
>     implements(IDriver,ILimoserviceContained)
>     _car = None
> 
>     def _getCar(self):
>       return self._car
> 
>     def _setCar(self, value):
>       self._car = removeSecurityProxy(value)
> 
>     car = property(_getCar,_setCar)
>   ...
> 
> Like that, any way the car property is modified, it's automatically
> unproxied and can be stored safely.
> 
> 
>   Thierry Florac



More information about the Zope3-users mailing list