Пример #1
0
class CITaskConfigManager(object):
    def __init__(self, mongo_host, mongo_port, db, collection):
        self.host = mongo_host
        self.port = mongo_port
        self.db = db
        self.collection = collection
        self.default_db = "doraemon"
        self.default_collection = "ci"
        self.mongo_helper = MongodbHelper(self.host, self.port)

    def save(self, value):
        return self.mongo_helper.save(self.db, self.collection, value)

    def remove(self, doc_id):
        result = self.mongo_helper.remove(self.db, self.collection, doc_id)
        if result == None:
            result = self.mongo_helper.remove(self.default_db,
                                              self.default_collection, doc_id)
        return result

    def get(self, doc_id):
        result = self.mongo_helper.get(self.db, self.collection, doc_id)
        if result == None:
            result = self.mongo_helper.get(self.default_db,
                                           self.default_collection, doc_id)
        return result
Пример #2
0
 def delete_value(self, file_id):
     mongo_helper = MongodbHelper(self.host, self.port)
     file_id = mongo_helper.remove(self.db, self.collection, file_id)
     file_id = mongo_helper.remove(self.default_db, self.default_collection,
                                   file_id)
     return file_id