DocumentSchema inside a Document instance.
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.
If you look here, I have used how it is used in the documentation. But I have realised you don't need to initialise the Address object in the SchemaProperty constructor. Instead just take out the (), making it a reference to the class type instead of an instance.
This seems to fix it but can other people to check just to make sure? Thanks
It was at first a feature. Maybe raising it on the ml for a discussion ?
Well I now have no problems with it when using without initialising, if you see in my comment.
well i'm not sure what you mean. Can you provide a short test about what do you expect and what is coming? Thanks!