Fixes multiple assignment issue preventing saves
Thanks to @wpjunior for the ticket and testcase Also fixed bug in BaseList fixes #195
This commit is contained in:
@@ -784,9 +784,9 @@ class BaseDocument(object):
|
||||
for field_name in self._fields:
|
||||
key = '%s.' % field_name
|
||||
field = getattr(self, field_name, None)
|
||||
if isinstance(field, EmbeddedDocument): # Grab all embedded fields that have been changed
|
||||
if isinstance(field, EmbeddedDocument) and field_name not in _changed_fields: # Grab all embedded fields that have been changed
|
||||
_changed_fields += ["%s%s" % (key, k) for k in field._get_changed_fields(key) if k]
|
||||
elif isinstance(field, (list, tuple)): # Loop list fields as they contain documents
|
||||
elif isinstance(field, (list, tuple)) and field_name not in _changed_fields: # Loop list fields as they contain documents
|
||||
for index, value in enumerate(field):
|
||||
if not hasattr(value, '_get_changed_fields'):
|
||||
continue
|
||||
@@ -858,7 +858,7 @@ class BaseList(list):
|
||||
def __setitem__(self, *args, **kwargs):
|
||||
if hasattr(self, 'instance') and hasattr(self, 'name'):
|
||||
self.instance._mark_as_changed(self.name)
|
||||
super(BaseDict, self).__setitem__(*args, **kwargs)
|
||||
super(BaseList, self).__setitem__(*args, **kwargs)
|
||||
|
||||
def __delitem__(self, *args, **kwargs):
|
||||
self.instance._mark_as_changed(self.name)
|
||||
|
||||
Reference in New Issue
Block a user