In Flask-PyMongo, verwenden sie self._Collection__database
das Datenbankobjekt darzustellen, dass diese Sammlung Objekt gehört:Flask-PyMongo: Wie kommt "self._Collection__database"?
class Collection(collection.Collection):
"""Custom sub-class of :class:`pymongo.collection.Collection` which
adds Flask-specific helper methods.
"""
def __getattr__(self, name):
attr = super(Collection, self).__getattr__(name)
if isinstance(attr, collection.Collection):
db = self._Collection__database
return Collection(db, attr.name)
return attr
Warum ist self._Collection__database
nicht self.__database
?
test <a>and <i>