Allow types contained by documents to serialize themselves
还没有人认领这个 Issue。
评估
调研方向
首先追踪 DictProperty 值的序列化方式,以及 ALLOWED_TYPES 在哪里拒绝 Animal。查看所请求的 to_json 和 from_json 契约,以及 MyDoc.animals 示例。完成的标准是:无需将 Animal 设为 CouchDB 模型,包含的自定义对象即可通过这些方法进行序列化和反序列化,并且不再引发现有异常。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 261
- 派生
- 90
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
benoitc/couchdbkit 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
benoitc/couchdbkit#181 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
benoitc/couchdbkit#196 ·
-
难度 3/5 1-2 天 新手友好度 35/100
benoitc/couchdbkit#194 ·
-
难度 4/5 3-5 天 新手友好度 30/100
benoitc/couchdbkit#193 · 2 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 48/100
benoitc/couchdbkit#192 ·
查看 benoitc/couchdbkit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
openvinotoolkit/openvino_notebooks#3858 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 88/100
hummingbot/hummingbot-api#256 ·
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
-
area:other help wanted
难度 2/5 1-3 小时 新手友好度 70/100
WingedGuardian/GENesis-AGI#4734 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
peach-mitao/peach#693 ·
维护者通常 1 天内回复