[Zope-dev] Re: Strange serializing error when commiting -> zope.sqlalchemy

Laurence Rowe l at lrowe.co.uk
Tue Jun 3 06:18:58 EDT 2008


Hermann Himmelbauer wrote:
> Am Montag, 2. Juni 2008 20:04 schrieb Hermann Himmelbauer:
>> Hi,
>> In my zope3 tests, I set up some basic test data. After that, I'm calling
>> transaction.commit(). However, I get the following traceback:
>>
>>
>> --------------- snip -------------------
>>   File "copy_reg.py", line 69, in _reduce_ex
>>     raise TypeError, "can't pickle %s objects" % base.__name__
>> TypeError: can't pickle module objects
>> ------------------ snip -------------------
> 
> I found it by myself: I registered a zope.sqlalchemy related utility, which 
> stores an engine (self.engine = create_engine(DSN,...)) and a scoped session 
> (self.Session = scoped_session(sessionmaker...)). These two objects cannot be 
> serialized, hence the above problem.
> 
> Now I'm unsure what to do about this problem - is there any code available 
> that demonstrates how to register SA engines/Sessions as utilities?

The simplest solution is to register the Session object as a global utility.

Laurence



More information about the Zope-Dev mailing list