[Zope-dev] UnpickleableError using SESSION in 2.7.2RC1
Brad Clements
bkc at murkworks.com
Mon Jul 19 11:26:51 EDT 2004
Can sessions store instance objects created by an external method?
I'm running Python 2.3.4 (also happens with 2.3.2)
I also get this error with Zope 2.7.0
I'm trying to save a simple instance in a session. The instance is created in an external
method. I can't figure out why I get this error at the end of the transaction:
Traceback (innermost last):
Module ZPublisher.Publish, line 107, in publish
Module Zope.App.startup, line 222, in commit
Module ZODB.Transaction, line 236, in commit
Module ZODB.Transaction, line 351, in _commit_objects
Module ZODB.Connection, line 416, in commit
- __traceback_info__: (('Products.Transience.TransientObject', 'TransientObject'),
'\x00\x00\x00\x00\x00\x00\x00%', '')
UnpickleableError: Cannot pickle <extension class Acquisition.ImplicitAcquirerWrapper at
409d7800> objects
My external method looks like this::
def CreateInstanceItem(**kw):
"""Generate an instance item"""
return InstanceItem(**kw)
And the InstanceItem is::
class InstanceItem(object):
__allow_access_to_unprotected_subobjects__=1
def __init__(self,**kw):
"""Initialize"""
self.__dict__ = kw
print "Created instance", self
def __repr__(self):
return repr(self.__dict__)
I get output like this from bin/runzope
Created instance {'dn': 'cn=brad,ou=sfiusa,ou=Public,dc=strader-ferris,dc=com', 'isManager':
1, 'preferences': None, 'firstname': 'Brad', 'orgname': 'Ross Video Ltd.', 'lastname':
'Clements', 'userid': 'bkc at murkworks.com', 'emailaddress': 'bkc at murkworks.com', 'user':
bkc at murkworks.com, 'orgid': 'rv', 'isCustomer': 1, 'uid': 3.0}
And my python script that calls the CreateInstanceItem looks like this::
I = container.CreateInstanceItem(userid=userid,
orgid=orgid,
dn=dn,
firstname=firstname,
lastname=lastname,
user=user, # zope user
uid=uid, # our internal uid
preferences=preferences and None,
emailaddress=emailaddress,
orgname=orgname,
isManager=isManager,
isCustomer=isCustomer)
SESSION['user_details'] = I
It seems like the 'I' object is wrapped somehow. From this script I tried
SESSION['user_details'] = I.aq_base
But I got an attribute error, possibly that's a security thing hiding aq_base.
Is there any way to store an instance in a SESSION?
--
Brad Clements, bkc at murkworks.com (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
More information about the Zope-Dev
mailing list