Exemplo n.º 1
0
    def load_db_params(self, gc):
        self.databases = tuple(self.to_iter(gc["databases"]))
        self.db_params = {}
        if not self.databases:
            return

        dbm = db_manager.db_manager()
        db_param_names = ("name", "db_host", "db_user", "db_pass", "pool_size", "max_overflow")
        for db_name in self.databases:
            conf_params = self.to_iter(gc[db_name + "_db"])
            params = dict(zip(db_param_names, conf_params))
            dbm.engines[db_name] = db_manager.get_engine(**params)
            self.db_params[db_name] = params

        dbm.type_db = dbm.engines[gc["type_db"]]
        dbm.relation_type_db = dbm.engines[gc["rel_type_db"]]

        prefix = "db_table_"
        for k, v in gc.iteritems():
            if k.startswith(prefix):
                params = list(self.to_iter(v))
                name = k[len(prefix) :]
                kind = params[0]
                if kind == "thing":
                    dbm.add_thing(name, [dbm.engines[n] for n in params[1:]])
                elif kind == "relation":
                    dbm.add_relation(name, params[1], params[2], [dbm.engines[n] for n in params[3:]])
        return dbm
Exemplo n.º 2
0
    def load_db_params(self, gc):
        self.databases = tuple(self.to_iter(gc['databases']))
        self.db_params = {}
        if not self.databases:
            return

        dbm = db_manager.db_manager()
        db_param_names = ('name', 'db_host', 'db_user', 'db_pass',
                          'pool_size', 'max_overflow')
        for db_name in self.databases:
            conf_params = self.to_iter(gc[db_name + '_db'])
            params = dict(zip(db_param_names, conf_params))
            dbm.engines[db_name] = db_manager.get_engine(**params)
            self.db_params[db_name] = params

        dbm.type_db = dbm.engines[gc['type_db']]
        dbm.relation_type_db = dbm.engines[gc['rel_type_db']]

        prefix = 'db_table_'
        for k, v in gc.iteritems():
            if k.startswith(prefix):
                params = list(self.to_iter(v))
                name = k[len(prefix):]
                kind = params[0]
                if kind == 'thing':
                    dbm.add_thing(name, [dbm.engines[n] for n in params[1:]])
                elif kind == 'relation':
                    dbm.add_relation(name, params[1], params[2],
                                     [dbm.engines[n] for n in params[3:]])
        return dbm
Exemplo n.º 3
0
    def load_db_params(self, gc):
        self.databases = tuple(self.to_iter(gc['databases']))
        self.db_params = {}
        if not self.databases:
            return

        dbm = db_manager.db_manager()
        db_param_names = ('name', 'db_host', 'db_user', 'db_pass', 'pool_size',
                          'max_overflow')
        for db_name in self.databases:
            conf_params = self.to_iter(gc[db_name + '_db'])
            params = dict(zip(db_param_names, conf_params))
            dbm.engines[db_name] = db_manager.get_engine(**params)
            self.db_params[db_name] = params

        dbm.type_db = dbm.engines[gc['type_db']]
        dbm.relation_type_db = dbm.engines[gc['rel_type_db']]
        dbm.hardcache_db = dbm.engines[gc['hardcache_db']]

        def split_flags(p):
            return ([n for n in p if not n.startswith("!")],
                    dict((n.strip('!'), True) for n in p if n.startswith("!")))

        prefix = 'db_table_'
        for k, v in gc.iteritems():
            if k.startswith(prefix):
                params = list(self.to_iter(v))
                name = k[len(prefix):]
                kind = params[0]
                if kind == 'thing':
                    engines, flags = split_flags(params[1:])
                    dbm.add_thing(name, [dbm.engines[n] for n in engines],
                                  **flags)
                elif kind == 'relation':
                    engines, flags = split_flags(params[3:])
                    dbm.add_relation(name, params[1], params[2],
                                     [dbm.engines[n] for n in engines],
                                     **flags)
        return dbm
Exemplo n.º 4
0
# CondeNet, Inc. All Rights Reserved.
################################################################################
from r2.lib.manager import db_manager
from pylons import g
try:
    #TODO: move?
    from r2admin.config.databases import *
except:
    pass

tz = g.tz

dbm = db_manager.db_manager()

main_engine = db_manager.get_engine(g.main_db_name,
                                    db_host = g.main_db_host,
                                    db_user = g.main_db_user,
                                    db_pass = g.main_db_pass)

comment_engine = db_manager.get_engine(g.comment_db_name,
                                    db_host = g.comment_db_host,
                                    db_user = g.comment_db_user,
                                    db_pass = g.comment_db_pass)

vote_engine = db_manager.get_engine(g.vote_db_name,
                                    db_host = g.vote_db_host,
                                    db_user = g.vote_db_user,
                                    db_pass = g.vote_db_pass)

change_engine = db_manager.get_engine(g.change_db_name,
                                      db_host = g.change_db_host,
                                      db_user = g.change_db_user,
Exemplo n.º 5
0
# CondeNet, Inc. All Rights Reserved.
################################################################################
from r2.lib.manager import db_manager
from pylons import g
try:
    #TODO: move?
    from r2admin.config.databases import *
except:
    pass

tz = g.tz

dbm = db_manager.db_manager()

main_engine = db_manager.get_engine(g.main_db_name,
                                    db_host=g.main_db_host,
                                    db_user=g.main_db_user,
                                    db_pass=g.main_db_pass)

comment_engine = db_manager.get_engine(g.comment_db_name,
                                       db_host=g.comment_db_host,
                                       db_user=g.comment_db_user,
                                       db_pass=g.comment_db_pass)

vote_engine = db_manager.get_engine(g.vote_db_name,
                                    db_host=g.vote_db_host,
                                    db_user=g.vote_db_user,
                                    db_pass=g.vote_db_pass)

change_engine = db_manager.get_engine(g.change_db_name,
                                      db_host=g.change_db_host,
                                      db_user=g.change_db_user,