Exemple #1
0
    def init_searches_conn(self):
        ''' Inits searches database before its first use. '''
        # Crea las colecciones capadas si no existen
        check_capped_collections(self.searches_conn.torrents, self._capped)

        # Comprueba índices
        check_collection_indexes(self.searches_conn.torrents, self._indexes)
        self.searches_conn.end_request()
Exemple #2
0
    def init_app(self, app):
        self.max_pool_size = app.config["DATA_SOURCE_MAX_POOL_SIZE"]

        if app.config.get("DATA_SOURCE_EXTRAS_RS", None):
            self.options = {
                "replicaSet": app.config["DATA_SOURCE_EXTRAS_RS"],
                "read_preference": pymongo.read_preferences.ReadPreference.SECONDARY_PREFERRED,
                "secondary_acceptable_latency_ms": app.config.get("SECONDARY_ACCEPTABLE_LATENCY_MS", 15),
                "tag_sets":app.config.get("DATA_SOURCE_EXTRAS_RS_TAG_SETS",[{}])
                }
        else:
            self.options = {"slave_okay":True}

        self.image_path = app.config["EXTRAS_IMAGE_PATH"]
        self.download_path = app.config["EXTRAS_DOWNLOAD_PATH"]

        self.titles = app.config.get("EXTRAS_CATEGORY_TITLES", {None:"all"})
        self.conn = pymongo.MongoClient(app.config["DATA_SOURCE_EXTRAS"], max_pool_size=self.max_pool_size, **self.options)
        self.db = self.conn.plugins

        check_collection_indexes(self.db, self._indexes)
Exemple #3
0
 def init_user_conn(self):
     '''
     Inits users database before its first use.
     '''
     check_collection_indexes(self.user_conn.users, self._indexes)
     self.user_conn.end_request()