[Zope3-dev] CustomWidgetFactory --> UnpickleableError:
Roger Ineichen
r.ineichen at projekt01.ch
Fri Apr 2 18:19:04 EST 2004
I got a error if I use CustomWidgetFactory in a EditView.
The add view is working but the edit view not.
If I change the familyname it seems ok. But if
I change the attributes of a child (class Person)
which is a Object(Field) it ends up in a "UnpickleableError".
If I add the Person as a content type I can edit the
Person without any problem.
UnpickleableError: Cannot pickle <type 'zope.security._proxy._Proxy'>
objects.
Does anybody have a example of using CustomWidgetFactory
and generating a EditView with Object(Field). (not in a Sequence)
The interface:
-----
class IFamily(IZope3SampleContent):
"""This interface represents a family.
A family is used for to store father, mother and children which
are implementations of IPerson.
"""
familyname = TextLine(
title=_(u"Familyname"),
description=_(u"The name of the family"),
default=u"",
required=True,
)
father = Object(title=u'Father',
description=u'The father of the family',
required = True,
readonly = False,
default = None,
schema = IPerson
)
mother = Object(title=u'Mother',
description=u'The mother of the family',
required = True,
readonly = False,
default = None,
schema = IPerson
)
....
-----
The class:
-----
class Family(Zope3SampleContent):
"""Family sample class
"""
implements(IFamily, IZope3SampleContained)
#father = FieldProperty(IFamily['father']) # also don't work with
FieldProperty
#mother = FieldProperty(IFamily['mother']) # "
def __init__(self, familyname=''):
self.familyname = familyname
self.father = None
self.mother = None
-----
The view class:
-----
father_w = CustomWidgetFactory(ObjectWidget, Person)
mother_w = CustomWidgetFactory(ObjectWidget, Person)
class FamilyAddView(EditView):
"""View for viewing a family"""
__used_for__ = IFamily
father_widget = father_w
mother_widget = mother_w
-----
The edit view:
-----
father_w = CustomWidgetFactory(ObjectWidget, Person)
mother_w = CustomWidgetFactory(ObjectWidget, Person)
class FamilyEditView(EditView):
"""View for editing a family"""
__used_for__ = IFamily
father_widget = father_w
mother_widget = mother_w
------
The traceback
------
2004-04-03T00:56:22 ERROR SiteError
http://localhost:8080/demo/zope3samples/folder/ineichen/@@edit.html
Traceback (most recent call last):
File "C:\projektCompiler\current\src\zope\publisher\publish.py", line 142,
in publish
publication.afterCall(request, object)
File "C:\projektCompiler\current\src\zope\app\publication\browser.py",
line 63, in afterCall
super(BrowserPublication, self).afterCall(request, ob)
File
"C:\projektCompiler\current\src\zope\app\publication\zopepublication.py",
line 155, in afterCall
txn.commit()
File "C:\projektCompiler\current\src\transaction\_transaction.py", line
254, in commit
self._commitResources(subtransaction)
File "C:\projektCompiler\current\src\transaction\_transaction.py", line
283, in _commitResources
rm.commit(self)
File "C:\projektCompiler\current\src\transaction\_transaction.py", line
459, in commit
self.manager.commit(o, txn)
File "C:\projektCompiler\current\src\ZODB\Connection.py", line 501, in
commit
self._store_objects(ObjectWriter(obj), transaction)
File "C:\projektCompiler\current\src\ZODB\Connection.py", line 520, in
_store_objects
p = writer.serialize(obj) # This calls __getstate__ of obj
File "C:\projektCompiler\current\src\ZODB\serialize.py", line 287, in
serialize
return self._dump(meta, obj.__getstate__())
File "C:\projektCompiler\current\src\ZODB\serialize.py", line 296, in
_dump
self._p.dump(state)
UnpickleableError: Cannot pickle <type 'zope.security._proxy._Proxy'>
objects
Regards
Roger Ineichen
_____________________________
Projekt01 GmbH
www.projekt01.ch
Langackerstrasse 8
6330 Cham
phone +41 (0)41 781 01 78
mobile +41 (0)79 340 52 32
fax +41 (0)41 781 00 78
email r.ineichen at projekt01.ch
_____________________________
END OF MESSAGE
More information about the Zope3-dev
mailing list