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.)
Thanks yet again!
2008-01-15T06:47:39 ERROR SiteError
http://localhost:2020/mylimo/+/limoService.Driver%3D
Traceback (most recent call last):
File C:\Python24\Lib\site-packages\zope\publisher\publish.py, line 138, in
publish
publication.afterCall(request, obj)
File C:\Python24\Lib\site-packages\zope\app\publication\browser.py, line
78, in afterCall
super(BrowserPublication, self).afterCall(request, ob)
File C:\Python24\Lib\site-packages\zope\app\publication\zopepublication.py,
line 167, in afterCall
txn.commit()
File C:\Python24\Lib\site-packages\transaction\_transaction.py, line 395,
in commit
self._commitResources()
File C:\Python24\Lib\site-packages\transaction\_transaction.py, line 495,
in _commitResources
rm.commit(self)
File C:\Python24\Lib\site-packages\ZODB\Connection.py, line 498, in commit
self._commit(transaction)
File C:\Python24\Lib\site-packages\ZODB\Connection.py, line 543, in _commit
self._store_objects(ObjectWriter(obj), transaction)
File C:\Python24\Lib\site-packages\ZODB\Connection.py, line 570, in
_store_objects
p = writer.serialize(obj) # This calls __getstate__ of obj
File C:\Python24\Lib\site-packages\ZODB\serialize.py, line 407, in serialize
return self._dump(meta, obj.__getstate__())
File C:\Python24\Lib\site-packages\ZODB\serialize.py, line 416, in _dump
self._p.dump(state)
UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy' objects
127.0.0.1 - - [15/Jan/2008:06:47:39 -0400] POST
/mylimo/+/limoService.Driver%3D HTTP/1.1 500 84
http://localhost:2020/mylimo/+/limoService.Driver=; Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
from zope.app import zapi
from zope.interface import implements
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained
# from persistent import Persistent
from interfaces import ICar, IDriver, ILimoservice, ILimoserviceContained
class Car(Contained):
implements(ICar,ILimoserviceContained)
model=u''
nPassengers=0
class Driver(Contained):
implements(IDriver,ILimoserviceContained)
car=None
class Limoservice(BTreeContainer):
implements(ILimoservice)
class CarView(object):
def message(self):
return 'car model %s holds %d passengers' % (self.context.model,
self.context.nPassengers)
class DriverView(object):
def message(self):
if self.context.car:
car=self.context.car
msg='driver drives car model %s, can carry %d
passengers' % (car.model,car.nPassengers)
else:
print 'driver has no car!'
msg='no car info'
return msg
from zope.formlib import form
class CarEdit(form.EditForm):
form_fields = form.Fields(ICar)
class DriverEdit(form.EditForm):
form_fields = form.Fields(IDriver)
class CarAddForm(form.AddForm):
form_fields = form.Fields(ICar)
def create(self,data):
obj=Car()
form.applyChanges(obj, self.form_fields, data)
return obj
class DriverAddForm(form.AddForm):
form_fields = form.Fields(IDriver)
def create(self,data):
obj=Driver()
form.applyChanges(obj, self.form_fields, data)
return obj
from zope.schema.vocabulary import SimpleVocabulary
def carsInParent(context):
'''returns child cars __name__ for subobjects of parent as a vocabulary'''
return SimpleVocabulary.fromItems(
[(k, v) for k, v in context.__parent__.items() if ICar.providedBy(v)])
configure
xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;
i18n_domain=limoService
interface
interface=.interfaces.ICar
type=zope.app.content.interfaces.IContentType
/
interface
interface=.interfaces.IDriver
type=zope.app.content.interfaces.IContentType
/
class class=.classes.Car
implements
interface=zope.annotation.interfaces.IAttributeAnnotatable
/
factory
id=limoService.classes.Car
description=a car
/
require
permission=zope.Public
interface=.interfaces.ICar
/
require
permission=zope.ManageContent
set_schema=.interfaces.ICar
/
/class
class class=.classes.Driver
implements