check for dynamic document, exclude id pk and _cls

This commit is contained in:
Rik 2013-09-03 11:25:45 +02:00 committed by Wilson Júnior
parent 4cca9f17df
commit 06064decd2

View File

@ -63,12 +63,13 @@ class BaseDocument(object):
# Check if there are undefined fields supplied, if so raise an
# Exception.
for var in values.keys():
if var not in self._fields.keys():
msg = (
"The field '{}' does not exist on the document '{}'"
).format(var, self._class_name)
raise FieldDoesNotExist(msg)
if not self._dynamic:
for var in values.keys():
if var not in self._fields.keys() + ['id', 'pk', '_cls']:
msg = (
"The field '{}' does not exist on the document '{}'"
).format(var, self._class_name)
raise FieldDoesNotExist(msg)
if self.STRICT and not self._dynamic:
self._data = StrictDict.create(allowed_keys=self._fields_ordered)()