Пример #1
0
def register_models(options):
    """Register Models and create properties"""
    supported_memcache_models = ast.literal_eval(options["backend_entities"])
    for supported_memcache_model in supported_memcache_models:
        model = utils.import_module(MODEL_PREFIX + supported_memcache_model)
        top_models.set_value(supported_memcache_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
Пример #2
0
def register_models(options):
    """Register Models and create properties"""
    supported_memcache_models = ast.literal_eval(
                    options["backend_entities"])
    for supported_memcache_model in supported_memcache_models:
        model = utils.import_module(MODEL_PREFIX + supported_memcache_model)
        top_models.set_value(supported_memcache_model, model)
        if model.__api__ is not None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
Пример #3
0
    def _init_models(self, model_list):
        for model in model_list:
            model_class = getattr(models, model)
            top_models.set_value(model, model_class)

            if model_class.__api__ is not None:
                api_path = '.'.join([__package__, 'api', model_class.__api__])
                api_module = sys.modules.get(api_path)
                if api_module is None:
                    api_module = utils.import_module(api_path)
                top_api.set_value(model_class.__api__, api_module.get())
Пример #4
0
    def _init_models(self, model_list):
        for model in model_list:
            model_path = '.'.join([__package__, 'models', model])
            module = utils.import_module(model_path)

            top_models.set_value(model, module)

            if module.__api__ is not None:
                api_path = '.'.join([__package__, 'api', module.__api__])
                api_module = utils.import_module(api_path)
                top_api.set_value(module.__api__, api_module.get())
Пример #5
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    supported_alchemy_models = ast.literal_eval(
                    options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Пример #6
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    # Need to decide.Not This is missing
    # and prevents foreign key reference checks.
    # _ENGINE.execute('pragma foreign_keys=on')
    supported_alchemy_models = ast.literal_eval(options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Пример #7
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    # Need to decide.Not This is missing
    # and prevents foreign key reference checks.
    # _ENGINE.execute('pragma foreign_keys=on')
    supported_alchemy_models = ast.literal_eval(
                    options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Пример #8
0
def configure_backend(options):
    api_obj = api.API(options)
    for name in api_obj.apis:
        top_api.set_value(name, getattr(api_obj, name))
    for model_name in models.__all__:
        top_models.set_value(model_name, getattr(models, model_name))