Allow dynamic dictionary-style field access

Allows the doc[key] syntax to work for dynamicembeddeddocument fields

Fixes #559
This commit is contained in:
Brian J. Dowling 2014-01-27 23:05:29 +00:00
parent 0da694b845
commit b085993901

View File

@ -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)