2
在燒瓶PyMongo,他們使用self._Collection__database
表示,這個集合對象所屬的數據庫對象:Flask-PyMongo:怎麼來「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
爲什麼self._Collection__database
不self.__database
?
test <a>and <i>