[Zope3-Users] UnpickleableError when adding object with reference
Thierry Florac
thierry.florac at onf.fr
Tue Jan 15 08:02:06 EST 2008
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
--
Chef de projet intranet/internet
Office National des Forêts - Département Informatique
2, Avenue de Saint-Mandé
75570 PARIS Cedex 12
Mél : thierry.florac at onf.fr
Tél. : +33 01.40.19.59.64
Fax. : +33 01.40.19.59.85
More information about the Zope3-users
mailing list