Dans Flask-PyMongo, ils utilisent self._Collection__database
pour représenter l'objet de base de données que cet objet de collection appartient à:Flask-PyMongo: comment se fait-il "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
Pourquoi pas self._Collection__database
self.__database
?
test <a>and <i>