MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / __setattr__

Method __setattr__

gridfs/asynchronous/grid_file.py:1238–1254  ·  view source on GitHub ↗
(self, name: str, value: Any)

Source from the content-addressed store, hash-verified

1236 raise AttributeError("GridIn object has no attribute '%s'" % name)
1237
1238 def __setattr__(self, name: str, value: Any) -> None:
1239 # For properties of this instance like _buffer, or descriptors set on
1240 # the class like filename, use regular __setattr__
1241 if name in self.__dict__ or name in self.__class__.__dict__:
1242 object.__setattr__(self, name, value)
1243 else:
1244 # All other attributes are part of the document in db.fs.files.
1245 # Store them to be sent to server on close() or if closed, send
1246 # them now.
1247 self._file[name] = value
1248 if self._closed:
1249 if _IS_SYNC:
1250 self._coll.files.update_one({"_id": self._file["_id"]}, {"$set": {name: value}})
1251 else:
1252 raise AttributeError(
1253 "AsyncGridIn does not support __setattr__ after being closed(). Set the attribute before closing the file or use AsyncGridIn.set() instead"
1254 )
1255
1256 async def set(self, name: str, value: Any) -> None:
1257 self._file[name] = value

Callers 5

__init__Method · 0.45
_ensure_indexesMethod · 0.45
abortMethod · 0.45
closeMethod · 0.45
__aexit__Method · 0.45

Calls 1

update_oneMethod · 0.45

Tested by

no test coverage detected