Merge branch 'single-work-op' of https://github.com/njoyce/mongoengine into 211
Conflicts: mongoengine/document.py tests/test_document.py
This commit is contained in:
		| @@ -84,6 +84,17 @@ class BaseDocument(object): | ||||
|         self._initialised = True | ||||
|         signals.post_init.send(self.__class__, document=self) | ||||
|  | ||||
|     def __delattr__(self, *args, **kwargs): | ||||
|         """Handle deletions of fields""" | ||||
|         field_name = args[0] | ||||
|         if field_name in self._fields: | ||||
|             default = self._fields[field_name].default | ||||
|             if callable(default): | ||||
|                 default = default() | ||||
|             setattr(self, field_name, default) | ||||
|         else: | ||||
|             super(BaseDocument, self).__delattr__(*args, **kwargs) | ||||
|  | ||||
|     def __setattr__(self, name, value): | ||||
|         # Handle dynamic data only if an initialised dynamic document | ||||
|         if self._dynamic and not self._dynamic_lock: | ||||
|   | ||||
| @@ -250,16 +250,16 @@ class Document(BaseDocument): | ||||
|                     return created | ||||
|  | ||||
|                 upsert = self._created | ||||
|                 update_query = {} | ||||
|  | ||||
|                 if updates: | ||||
|                     last_error = collection.update(select_dict, | ||||
|                         {"$set": updates}, upsert=upsert, safe=safe, | ||||
|                         **write_options) | ||||
|                     created = is_new_object(last_error) | ||||
|                     update_query["$set"] = updates | ||||
|                 if removals: | ||||
|                     last_error = collection.update(select_dict, | ||||
|                         {"$unset": removals}, upsert=upsert, safe=safe, | ||||
|                         **write_options) | ||||
|                     created = created or is_new_object(last_error) | ||||
|                     update_query["$unset"] = removals | ||||
|                 if updates or removals: | ||||
|                     last_error = collection.update(select_dict, update_query, | ||||
|                                     upsert=upsert, safe=safe, **write_options) | ||||
|                     created = is_new_object(last_error) | ||||
|  | ||||
|             warn_cascade = not cascade and 'cascade' not in self._meta | ||||
|             cascade = (self._meta.get('cascade', True) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user