[ZODB-Dev] None-persistent behaviour of BTree subclasses

pm5 at matilda.fiorile.org pm5 at matilda.fiorile.org
Sun Apr 4 05:14:49 EDT 2004


Hi,

I've got some behaviour of BTrees not as I expected, and came up with a
test case addressing this problem.

It seems that attributes of BTree subclasses are not saved. The
following code raises an ``AssertionError: None != 'foo''' at the
assertEqual line.  Descendants of Persistent (just change the definition
of UserDefinedClass and run) perserves this attribute correctly.

I'm not sure if my testing style violates some disciplins of ZODB (use
of connections, for one thing), so I'm posting the whole testing script.
I would be glad if someone could point out any of the problems.


==== Test Case ====

from ZEO import ClientStorage
from ZODB import DB
import unittest
from BTrees.OOBTree import OOBTree
from persistent import Persistent


addr = '127.0.0.1', 8081

def getConn() :
    return DB(ClientStorage.ClientStorage(addr)).open()

class UserDefinedClass(OOBTree) :
    other = None

class PersistentTest(unittest.TestCase) :
    def setUp(self) :
        root = self.root = getConn().root()
        root['one'] = UserDefinedClass()
        root['one'].other = 'foo'
        get_transaction().commit()

    def tearDown(self) :
        del self.root['one']
        get_transaction().commit()

    def testAnotherConnection(self) :
        root = getConn().root()
        # XXX this will break.  attribute is reset to None.
        self.assertEqual(root['one'].other, 'foo')

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040404/d4ec652b/attachment.bin


More information about the ZODB-Dev mailing list