def _connect(self):
"""Connecting to mongo database."""
try:
self.connection = Connection(host=self.host, port=self.port)
except AutoReconnect, e:
if self.fail_silently:
return
else:
raise AutoReconnect(e)
self.db = self.connection[self.database_name]
if self.username is not None and self.password is not None:
self.authenticated = self.db.authenticate(self.username, self.password)
if self.collection_name not in self.db.collection_names():
self.db.create_collection(self.collection_name,size=512000000,capped=True,max=200)
self.collection = self.db[self.collection_name]
评论列表
文章目录