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 
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 
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):
    def __init__(self,**kw):
        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', 
1, 'preferences': None, 'firstname': 'Brad', 'orgname': 'Ross Video Ltd.', 'lastname': 
'Clements', 'userid': '[EMAIL PROTECTED]', 'emailaddress': '[EMAIL PROTECTED]', 
[EMAIL PROTECTED], 'orgid': 'rv', 'isCustomer': 1, 'uid': 3.0}

And my python script that calls the CreateInstanceItem looks like this::

I = container.CreateInstanceItem(userid=userid,
    user=user,  # zope user
    uid=uid,    # our internal uid
    preferences=preferences and None,

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,                [EMAIL PROTECTED]   (315)268-1000                          (315)268-9812 Fax                   AOL-IM: BKClements

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to