[Zope] question about copyng btree elements

Tres Seaver tseaver at palladion.com
Wed Dec 16 16:22:43 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yuri wrote:
> Hi!
> 
> I've a Zope BTree called answers. It contains PersistentMapping objects:
> 
> self.answers[userid] = PersistentMapping(value=value,
>                                                  comments=comments)
> 
> value can be a string, a list or a dictionary
> 
> what happen exactly if I do: question.answers[a_userdid] = 
> question.answers[another_user_id] ?
> 
>  From my (poor) tests they seems not to share anything, I mean I can 
> modify question.answers[a_userdid] and question.answers[another_user_id] 
> is untouched.
> 
> Is this true? Should I beware of something?

I can't reproduce your reported behavior::

- --------------------- $< ------------------------------
$ bin/virtualenv-2.6 --no-site-packages /tmp/yuri
...
$ cd /tmp/yuri/
$ bin/easy_install ZODB3
...
$ bin/python
...
>>> from BTrees.OOBTree import OOBTree
>>> from persistent.mapping import PersistentMapping
>>> answers = OOBTree()
>>> john = PersistentMapping(value="John's value",
... comment="John's comment")
>>> answers['john'] = john
>>> answers['fred'] = answers['john']
>>> answers['fred'] is john
True
>>> print john
{'comment': "John's comment", 'value': "John's value"}
>>> answers['fred']['value'] = "Fred's value"
>>> print john
{'comment': "John's comment", 'value': "Fred's value"}
- --------------------- $< ------------------------------


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkspT6MACgkQ+gerLs4ltQ78PgCfRQMXXXDUOSSuViYtBW18muM7
oVYAoK5iL9klE15WBhjvte8KjNNNUUKt
=br64
-----END PGP SIGNATURE-----



More information about the Zope mailing list