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.)

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):
    _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
  Tél. : +33
  Fax. : +33

Zope3-users mailing list

Reply via email to