Clone doesn't work as expected
Just to note, this issue was in couchdbkit before the recent changes to clone. And it's still here after the recent commits. (It just so happens that this affected me at around the same time!)
Also I am not sure if this is an issue or bug, or if its unexpected behaviour.
>>> from couchdbkit import *
>>> class Person(Document):
... name = StringProperty()
...
>>> person_one = Person()
>>> person_two = person_one.clone()
>>> person_one.name = 'XYZ'
>>> person_two.name
u'XYZ'
>>> person_one
<__main__.Person object at 0x027EA170>
>>> person_two
<__main__.Person object at 0x04562530>
As you can see. If I change a property in person_one it is changing all the names for anything that was cloned from person_one, even though the new object coming back from clone() is a brand new object. It just seems it's only making a copy of the Document object, while the property objects inside the new copy are still pointing to the old property objects.
I have tried copy and deepcopy from the copy module; copy runs, but I get the same result. deepcopy throws an error.
I am using the latest version of couchdbkit.
Thanks.
afaik it was designed like this (you can check it in unitests) . Maybe this isn't a good idea though. Let's raise it on the ml and ask if people have some code based on it ?