[Zope-dev] zc.relationship - can't pickle module objects
Martin Aspeli
optilude+lists at gmail.com
Mon Mar 16 08:39:40 EDT 2009
Gary Poster wrote:
> On Mar 16, 2009, at 4:02 AM, Martin Aspeli wrote:
>
>> Hi,
>>
>> I *think* this is a bug in zc.relationship, but I'm not quite sure.
>>
>> I'm using ZODB3 3.8.1 (to get BLOB support) and trying to install
>> plone.app.relations, which depends on zc.relationship 1.0.2. In
>> particular, it subclasses zc.relationship.shared.Container, and
>> stores
>> a zc.relationship.index.Index object in self.relationIndex.
>>
>> Now, the __init__ of zc.relationship.index.Index, which derives from
>> Persistent, contains the code below. In self._relTools and and
>> self._attrs, there are a pile of modules, types and functions being
>> stored. I think these are causing the ZODB to barf. Interestingly,
>> with
>> whatever version of ZODB that comes with Zope 2.10 (3.7?), there's no
>> problem.
>>
>> Any ideas how to work around this, or even why it's a problem in one
>> version of the ZODB but not another?
>
> No idea yet. What's the barf's traceback?
Mmmm... it seems that zc.relationship 1.1 fixes the issue, but has some
other problems (an undefined variable minValues or similar - I haven't
got a build with this version in it right now); 2.0dev seems better,
albeit a bit scary at pre-alpha. Also, I think 2.0dev *requires* ZODB
3.8, though, which means we have to choose one or the other. Ideally,
I'd like a version of plone.relations that works with both ZODB 2.7 and 2.8.
I'm still having some problems with zc.relationship 2.0dev interacting
with five.intid (which has some special path handling to aq-wrap objects
that are turned from key references), though I'm hoping to work around them.
The traceback was:
File
"/Users/optilude/.buildout/zope/Zope-2.10.6-final-py2.4/lib/python/ZServer/PubCore/ZServerPublisher.py",
line 25, in __init__
response=b)
File
"/Users/optilude/.buildout/zope/Zope-2.10.6-final-py2.4/lib/python/ZPublisher/Publish.py",
line 401, in publish_module
environ, debug, request, response)
File
"/Users/optilude/.buildout/zope/Zope-2.10.6-final-py2.4/lib/python/ZPublisher/Publish.py",
line 202, in publish_module_standard
response = publish(request, module_name, after_list, debug=debug)
File
"/Users/optilude/.buildout/eggs/Products.PDBDebugMode-0.2-py2.4.egg/Products/PDBDebugMode/__init__.py",
line 47, in pdb_publish
mapply=mapply, )
File
"/Users/optilude/.buildout/zope/Zope-2.10.6-final-py2.4/lib/python/ZPublisher/Publish.py",
line 125, in publish
transactions_manager.commit()
File
"/Users/optilude/.buildout/zope/Zope-2.10.6-final-py2.4/lib/python/Zope2/App/startup.py",
line 238, in commit
transaction.commit()
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/transaction/_manager.py",
line 93, in commit
return self.get().commit()
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/transaction/_transaction.py",
line 328, in commit
t, v, tb = self._saveAndGetCommitishError()
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/transaction/_transaction.py",
line 325, in commit
self._commitResources()
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/transaction/_transaction.py",
line 424, in _commitResources
rm.commit(self)
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/ZODB/Connection.py",
line 541, in commit
self._commit(transaction)
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/ZODB/Connection.py",
line 586, in _commit
self._store_objects(ObjectWriter(obj), transaction)
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/ZODB/Connection.py",
line 620, in _store_objects
p = writer.serialize(obj) # This calls __getstate__ of obj
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/ZODB/serialize.py",
line 407, in serialize
return self._dump(meta, obj.__getstate__())
File
"/Users/optilude/.buildout/eggs/ZODB3-3.8.1-py2.4-macosx-10.3-i386.egg/ZODB/serialize.py",
line 416, in _dump
self._p.dump(state)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/copy_reg.py",
line 69, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle module objects
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Zope-Dev
mailing list