[Zope3-Users] Persistent subclasses in tests

Darryl Cousins darryl at darrylcousins.net.nz
Sun Jul 23 18:59:57 EDT 2006


I've have a problem with the following and I hope someone can shed some
light for me, I can't figure out what I am missing::

    >>> from ZODB.tests.util import DB
    >>> import transaction
    >>> db = DB()
    >>> conn = db.open()
    >>> root = conn.root()

    >>> from persistent import Persistent
    >>> p = Persistent()
    >>> root['p'] = p

Thats fine, but::

    >>> class TestItem(Persistent):
    ...     pass

    >>> item = TestItem()
    >>> root['item'] = item

    >>> transaction.commit()
    Traceback (most recent call last):
      File "/opt/zope/zope3/src/zope/testing/doctest.py", line 1361, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[28]>", line 1, in ?
      File "/opt/zope/zope3/src/transaction/_manager.py", line 96, in commit
        return self.get().commit(sub, deprecation_wng=False)
      File "/opt/zope/zope3/src/transaction/_transaction.py", line 395, in commit
      File "/opt/zope/zope3/src/transaction/_transaction.py", line 495, in _commitResources
      File "/opt/zope/zope3/src/ZODB/Connection.py", line 484, in commit
      File "/opt/zope/zope3/src/ZODB/Connection.py", line 526, in _commit
        self._store_objects(ObjectWriter(obj), transaction)
      File "/opt/zope/zope3/src/ZODB/Connection.py", line 553, in _store_objects
        p = writer.serialize(obj)  # This calls __getstate__ of obj
      File "/opt/zope/zope3/src/ZODB/serialize.py", line 407, in serialize
        return self._dump(meta, obj.__getstate__())
      File "/opt/zope/zope3/src/ZODB/serialize.py", line 416, in _dump
    PicklingError: Can't pickle <class 'TestItem'>: attribute lookup __builtin__.TestItem failed

More information about the Zope3-users mailing list