MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / __set__

Method __set__

mongoengine/fields.py:1862–1882  ·  view source on GitHub ↗
(self, instance, value)

Source from the content-addressed store, hash-verified

1860 return grid_file
1861
1862 def __set__(self, instance, value):
1863 key = self.name
1864 if (
1865 hasattr(value, "read") and not isinstance(value, GridFSProxy)
1866 ) or isinstance(value, (bytes, str)):
1867 # using "FileField() = file/string" notation
1868 grid_file = instance._data.get(self.name)
1869 # If a file already exists, delete it
1870 if grid_file:
1871 try:
1872 grid_file.delete()
1873 except Exception:
1874 pass
1875
1876 # Create a new proxy object as we don't already have one
1877 instance._data[key] = self.get_proxy_obj(key=key, instance=instance)
1878 instance._data[key].put(value)
1879 else:
1880 instance._data[key] = value
1881
1882 instance._mark_as_changed(key)
1883
1884 def get_proxy_obj(self, key, instance, db_alias=None, collection_name=None):
1885 if db_alias is None:

Callers

nothing calls this directly

Calls 5

get_proxy_objMethod · 0.95
getMethod · 0.45
deleteMethod · 0.45
putMethod · 0.45
_mark_as_changedMethod · 0.45

Tested by

no test coverage detected