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
精彩评论