【发布时间】:2012-04-09 02:47:52
【问题描述】:
在Flask-PyMongo中,他们使用self._Collection__database来表示这个Collection对象所属的数据库对象:
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>
【问题讨论】: