Allow types contained by documents to serialize themselves
- Dominant language
- Python
- Stars
- 263
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
class MyDoc(Document):
animals = DictProperty()
class Animal(object):
def **init**():
self.name = "Joe"
self.age = 14
def to_json():
"""Code to serialize to json"""
def from_json:
"""Code to load from json"""
...
The animal class intentional is not a couchdb model and we don't want to tie it to couchdb. What we want is being able to have it automatically serialized and deserialized by couchdbkit calling these methods it implements. In this case the contract would be to_json and from_json.
doc = MyDoc()
doc.animals['horsea'] = Animal(...)
doc.animals['horseb'] = Animal(...)
doc.save()
Currently this will raise an exception saying that Animal is not in ALLOWED_TYPES.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.