Allow dynamic dictionary-style field access
Allows the doc[key] syntax to work for dynamicembeddeddocument fields Fixes #559
This commit is contained in:
parent
0da694b845
commit
b085993901
@ -182,7 +182,7 @@ class BaseDocument(object):
|
|||||||
"""Dictionary-style field access, set a field's value.
|
"""Dictionary-style field access, set a field's value.
|
||||||
"""
|
"""
|
||||||
# Ensure that the field exists before settings its value
|
# Ensure that the field exists before settings its value
|
||||||
if name not in self._fields:
|
if not self._dynamic and name not in self._fields:
|
||||||
raise KeyError(name)
|
raise KeyError(name)
|
||||||
return setattr(self, name, value)
|
return setattr(self, name, value)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user