benoitc / benoitc/couchdbkit

DocumentSchema inside a Document instance.

Open
#91 4 comments 0 reactions 0 assignees View on GitHub
Need Feedback
Dominant language
Python
Stars
263
Forks
90
PR merge metrics
No merged PRs in 30d

Description

This may have something to do with the clone issue.

```
>>> from couchdbkit import *
>>> class Address(DocumentSchema):
... address = StringProperty()
...
>>> class Person(Document):
... name = StringProperty()
... address = SchemaProperty(Address())
...
>>> p = Person()
>>> p.name = 'XXX'
>>> p.address.address = 'XXX ADDRESS'
>>> p.name
u'XXX'
>>> p.address.address
u'XXX ADDRESS'
>>> p2 = Person()
>>> p2.address.address
u'XXX ADDRESS'
>>> p2.name
```

As you can see, because I am declaring Address() in the constructor of SchemaProperty, any new instances always point to the same object.
I have tried to get around this by trying to make a new Address object in **init**, but I cannot seem to get it to work.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.