开发者

An optional dict in the structure with MongoKit

I've got MongoKit structure like th开发者_运维技巧is:

structure = {
  ...

  'plugin': {
    'id': unicode,
    'title': unicode,
    'description': unicode,

  ...
}

However, not all documents will have the plugin key. If they do, I'd like it to be validated against the structure.

required_fields does not include plugin. (plugin isn't a required key.)

I've tried 'plugin': OR(None, {...}), but OR doesn't like None as a value.

Any ideas?


Looks like a bug in 0.5:

http://bitbucket.org/namlook/mongokit/issue/78/not-required-fields-wrongly-validates#comment-234872

Discussion and temporary workaround here:

http://groups.google.com/group/mongokit/browse_thread/thread/18fe4081a306e93e

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜