class MongofsAccess(): '''A class of mongodb gridfs access''' def __init__(self): self.mongo_db = MongoPool() def __del__(self): self.mongo_db = None # 插入网页列表 def insertJMPages(self, pages): try: _key, _pages_d = pages data = {"key":_key, "pages":_pages_d} c = _key[:8] db_name = "jm" + c self.mongo_db.insertPage(db_name, c, data) except Exception, e: Common.log('# insertJMPages exception: %s' % e)
class MongofsAccess(): '''A class of mongodb gridfs access''' def __init__(self): self.mongo_db = MongoPool() def __del__(self): self.mongo_db = None # 插入网页列表 def insertTCPages(self, pages): try: _key, _pages_d = pages data = {"key": _key, "pages": _pages_d} c = _key[:8] db_name = "tc" + c self.mongo_db.insertPage(db_name, c, data) except Exception, e: Common.log('# insertTCPages exception: %s' % e)
class MongofsAccess(): '''A class of mongodb gridfs access''' def __init__(self): self.mongo_db = MongoPool() def __del__(self): self.mongo_db = None # 插入网页列表 def insertTBPages(self, pages): try: _key, _pages_d = pages data = {"key":_key, "pages":_pages_d} c = _key[:8] self.mongo_db.insertTBPage(c, data) except Exception, e: print '# insertTBPages exception:', e traceback.print_exc()
def makeService(self, options): port = options['port'] root = Resource() mongoPool = MongoPool() log.discardLogs() #reactor.addSystemEventTrigger('before', 'shutdown', mongoPool.shutdown) root.putChild(mongoPool.version, mongoPool) factory = Site(root) httpService = internet.TCPServer(port, factory) return httpService
def __init__(self): self.mongo_db = MongoPool()