Clone doesn't work as expected
@benoitc ci sta già lavorando.
Dal 5/5/2011.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 261
- Fork
- 90
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di benoitc/couchdbkit
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
benoitc/couchdbkit#181 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
benoitc/couchdbkit#196 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
benoitc/couchdbkit#194 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
benoitc/couchdbkit#193 · 2 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
benoitc/couchdbkit#192 ·
Tutte le issue di benoitc/couchdbkit
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
-
area:other help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
WingedGuardian/GENesis-AGI#4734 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
peach-mitao/peach#693 ·
I maintainer di solito rispondono entro 1 giorno
-
Failed result serialization destroys a previously saved JSON resultForse già presa @chessing234 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/evaluate#867 ·
-
FTP reads inside a transaction use a nonexistent staging pathForse già presa @Harsh23Kashyap l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fsspec/filesystem_spec#2463 ·
I maintainer di solito rispondono entro 1 giorno