【发布时间】:2015-07-29 21:37:52
【问题描述】:
给定一个带有 Content-Type: application/json 的 POST 请求和 ["foo", "bar"] 的主体,我如何使用 Cornice 在 Pyramid 中创建一个漏勺模式来反序列化它。
这是我想出的:
class SimpleList(colander.SequenceSchema):
items = colander.SchemaNode(colander.String())
它在带有香草滤锅的 CLI 中运行良好。但是,当我像这样在 Cornice 服务上使用它时:
@simple_list_service.post(schema=SimpleList)
def simple_list_post(request):
print(request.validated)
我明白了:
{"errors": [{"name": "items", "description": "items is missing", "location": "body"}], "status": "error"}
有什么建议吗?
谢谢!
【问题讨论】:
标签: python pyramid colander cornice