当前位置: 首页>>代码示例>>Python>>正文


Python BlokManager.load方法代码示例

本文整理汇总了Python中anyblok.blok.BlokManager.load方法的典型用法代码示例。如果您正苦于以下问题:Python BlokManager.load方法的具体用法?Python BlokManager.load怎么用?Python BlokManager.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在anyblok.blok.BlokManager的用法示例。


在下文中一共展示了BlokManager.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: anyblok_createdb

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
def anyblok_createdb():
    """Create a database and install blok from config"""
    load_init_function_from_entry_points()
    Configuration.load('createdb')
    configuration_post_load()
    BlokManager.load()
    db_name = get_db_name()

    db_template_name = Configuration.get('db_template_name', None)
    url = Configuration.get('get_url')(db_name=db_name)
    create_database(url, template=db_template_name)
    registry = RegistryManager.get(db_name)
    if registry is None:
        return

    if Configuration.get('install_all_bloks'):
        bloks = registry.System.Blok.list_by_state('uninstalled')
    else:
        install_bloks = Configuration.get('install_bloks') or []
        iou_bloks = Configuration.get('install_or_update_bloks') or []
        bloks = list(set(install_bloks + iou_bloks))

    registry.upgrade(install=bloks)
    registry.commit()
    registry.close()
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:27,代码来源:scripts.py

示例2: test_get_invalid_blok

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def test_get_invalid_blok(self):
     try:
         BlokManager.load()
         BlokManager.get('invalid blok')
         self.fail('No exception when get invalid blok')
     except BlokManagerException:
         pass
开发者ID:petrus-v,项目名称:AnyBlok,代码行数:9,代码来源:test_blok.py

示例3: createdb

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
def createdb(application, configuration_groups, **kwargs):
    """ Create a database and install blok from config

    :param application: name of the application
    :param configuration_groups: list configuration groupe to load
    :param \**kwargs: ArgumentParser named arguments
    """
    format_configuration(configuration_groups,
                         'create_db', 'install-bloks',
                         'install-or-update-bloks')
    load_init_function_from_entry_points()
    Configuration.load(application, configuration_groups=configuration_groups,
                       **kwargs)
    BlokManager.load()
    db_name = Configuration.get('db_name')
    db_template_name = Configuration.get('db_template_name', None)
    url = Configuration.get('get_url')(db_name=db_name)
    create_database(url, template=db_template_name)
    registry = RegistryManager.get(db_name)
    if registry is None:
        return

    if Configuration.get('install_all_bloks'):
        bloks = registry.System.Blok.list_by_state('uninstalled')
    else:
        install_bloks = Configuration.get('install_bloks') or []
        iou_bloks = Configuration.get('install_or_update_bloks') or []
        bloks = list(set(install_bloks + iou_bloks))

    registry.upgrade(install=bloks)
    registry.commit()
    registry.close()
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:34,代码来源:scripts.py

示例4: load

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def load(self):
     BlokManager.load()
     preload_databases()
     config = Configurator()
     config.include_from_entry_point()
     config.load_config_bloks()
     return config.make_wsgi_app()
开发者ID:AnyBlok,项目名称:Anyblok_Pyramid,代码行数:9,代码来源:gunicorn.py

示例5: anyblok_wsgi

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
def anyblok_wsgi(application, configuration_groups, **kwargs):
    """
    :param application: name of the application
    :param configuration_groups: list configuration groupe to load
    :param \**kwargs: ArgumentParser named arguments
    """
    format_configuration(configuration_groups, 'preload', 'pyramid-debug',
                         'wsgi')
    load_init_function_from_entry_points()
    Configuration.load(application,
                       configuration_groups=configuration_groups, **kwargs)
    BlokManager.load()
    config = Configurator()
    config.include_from_entry_point()
    config.load_config_bloks()

    wsgi_host = Configuration.get('wsgi_host')
    wsgi_port = int(Configuration.get('wsgi_port'))

    app = config.make_wsgi_app()
    server = make_server(wsgi_host, wsgi_port, app)
    preload_databases()

    logger.info("Serve forever on %r:%r" % (wsgi_host, wsgi_port))
    server.serve_forever()
开发者ID:jssuzanne,项目名称:Anyblok_Pyramid,代码行数:27,代码来源:scripts.py

示例6: load_registry

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
    def load_registry(self):
        if self.enabled and self.registryLoaded is False:
            # Load the registry here not in configuration,
            # because the configuration are not load in order of score
            self.registryLoaded = True
            BlokManager.load()
            load_init_function_from_entry_points(unittest=True)
            Configuration.load_config_for_test()
            Configuration.parse_options(self.AnyBlokOptions, ('bloks',))
            db_name = Configuration.get('db_name')
            if not db_name:
                raise Exception("No database defined to run Test")

            registry = RegistryManager.get(db_name)
            if registry:
                installed_bloks = registry.System.Blok.list_by_state(
                    "installed")
                selected_bloks = Configuration.get('selected_bloks')
                if not selected_bloks:
                    selected_bloks = installed_bloks

                unwanted_bloks = Configuration.get('unwanted_bloks')
                if unwanted_bloks is None:
                    unwanted_bloks = []

                self.bloks_path = [BlokManager.getPath(x)
                                   for x in BlokManager.ordered_bloks]

                self.authoried_bloks_test_files = [
                    path for blok in installed_bloks
                    if blok in selected_bloks and blok not in unwanted_bloks
                    for path in [join(BlokManager.getPath(blok), 'tests')]
                    if exists(path)]
                registry.close()  # free the registry to force create it again
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:36,代码来源:plugins.py

示例7: setUp

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def setUp(self):
     super(TestBlok, self).setUp()
     self.__class__.init_configuration_manager()
     self.__class__.createdb(keep_existing=False)
     BlokManager.load(entry_points=('bloks', 'test_bloks'))
     registry = RegistryManager.get(Configuration.get('db_name'))
     registry.commit()
     registry.close()
开发者ID:AnyBlok,项目名称:AnyBlok_Multi_Engines,代码行数:10,代码来源:test_blok.py

示例8: test_load_anyblok

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
    def test_load_anyblok(self):
        BlokManager.load()
        if not BlokManager.list():
            self.fail('No blok load')
        if not BlokManager.has('anyblok-core'):
            self.fail("The blok 'anyblok-core' is missing")

        BlokManager.get('anyblok-core')
开发者ID:petrus-v,项目名称:AnyBlok,代码行数:10,代码来源:test_blok.py

示例9: test_reload

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def test_reload(self):
     BlokManager.load()
     BlokManager.set('invalid blok', None)
     BlokManager.get('invalid blok')
     BlokManager.reload()
     try:
         BlokManager.get('invalid blok')
         self.fail("Reload classmethod doesn't reload the bloks")
     except BlokManagerException:
         pass
开发者ID:petrus-v,项目名称:AnyBlok,代码行数:12,代码来源:test_blok.py

示例10: setUpClass

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
    def setUpClass(cls):
        """ Intialialise the configuration manager """

        super(DBTestCase, cls).setUpClass()
        cls.init_configuration_manager()
        if cls.createdb(keep_existing=True):
            BlokManager.load(entry_points=('bloks', 'test_bloks'))
            registry = cls.getRegistry()
            registry.commit()
            registry.close()
            BlokManager.unload()
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:13,代码来源:testcase.py

示例11: test_anyblok_core_loaded

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def test_anyblok_core_loaded(self):
     BlokManager.load()
     is_exist = 'anyblok-core' in RegistryManager.loaded_bloks
     self.assertEqual(is_exist, True)
     anyblokcore = RegistryManager.loaded_bloks['anyblok-core']
     self.assertEqual(len(anyblokcore['Core']['Base']), 1)
     self.assertEqual(len(anyblokcore['Core']['SqlBase']), 1)
     self.assertEqual(len(anyblokcore['Core']['SqlViewBase']), 1)
     self.assertEqual(len(anyblokcore['Core']['Session']), 1)
     self.assertEqual(len(anyblokcore['Core']['Query']), 1)
     self.assertEqual(len(anyblokcore['Core']['InstrumentedList']), 1)
     is_exist = 'Model.System' in anyblokcore['Model']
     self.assertEqual(is_exist, True)
     BlokManager.unload()
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:16,代码来源:test_registry_manager.py

示例12: setUpClass

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
    def setUpClass(cls):
        super(TestMigration, cls).setUpClass()
        cls.init_configuration_manager()
        cls.createdb()
        BlokManager.load()

        register = Declarations.register
        Model = Declarations.Model

        cls.loaded_bloks = deepcopy(RegistryManager.loaded_bloks)
        EnvironmentManager.set('current_blok', 'anyblok-core')

        @register(Model)
        class Test:
            integer = Int(primary_key=True)
            other = Str()

        @register(Model)
        class TestUnique:
            integer = Int(primary_key=True)
            other = Str(unique=True)

        @register(Model)
        class TestFKTarget:
            integer = Int(primary_key=True)

        @register(Model)
        class TestFK:
            integer = Int(primary_key=True)
            other = Int(foreign_key=Model.TestFKTarget.use('integer'))

        @register(Model)
        class TestM2M1:
            idmodel1 = Int(primary_key=True)

        @register(Model)
        class TestM2M2:
            idmodel2 = Int(primary_key=True)
            rel_m2m = Many2Many(label="Rel", model=Model.TestM2M1,
                                join_table='reltable',
                                remote_columns='idmodel1',
                                m2m_remote_columns='idmodel1',
                                local_columns='idmodel2',
                                m2m_local_columns='idmodel2',
                                many2many='rel_m2m_inv')

        EnvironmentManager.set('current_blok', None)
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:49,代码来源:test_migration.py

示例13: wsgi

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
def wsgi():
    """Simple wsgi server for dev
    """
    load_init_function_from_entry_points()
    Configuration.load('pyramid')
    configuration_post_load()
    BlokManager.load()
    config = Configurator()
    config.include_from_entry_point()
    config.load_config_bloks()

    wsgi_host = Configuration.get('wsgi_host')
    wsgi_port = int(Configuration.get('wsgi_port'))

    app = config.make_wsgi_app()
    server = make_server(wsgi_host, wsgi_port, app)
    preload_databases(loadwithoutmigration=False)

    logger.info("Serve forever on %r:%r" % (wsgi_host, wsgi_port))
    server.serve_forever()
开发者ID:AnyBlok,项目名称:Anyblok_Pyramid,代码行数:22,代码来源:scripts.py

示例14: setUpClass

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
    def setUpClass(cls):
        super(TestMigration, cls).setUpClass()
        cls.init_configuration_manager()
        cls.createdb()
        BlokManager.load()

        register = Declarations.register
        Model = Declarations.Model

        cls.loaded_bloks = deepcopy(RegistryManager.loaded_bloks)
        EnvironmentManager.set('current_blok', 'anyblok-core')

        @register(Model)
        class Test:
            integer = Int(primary_key=True)
            other = Str()

        @register(Model)
        class TestUnique:
            integer = Int(primary_key=True)
            other = Str(unique=True)

        @register(Model)
        class TestIndex:
            integer = Int(primary_key=True)
            other = Str(index=True)

        @register(Model)
        class TestCheck:
            integer = Int(primary_key=True)

            @classmethod
            def define_table_args(cls):
                table_args = super(TestCheck, cls).define_table_args()
                return table_args + (
                    CheckConstraint('integer > 0', name='test'),)

        @register(Model)
        class TestCheckLongConstraintName:
            integer = Int(primary_key=True)

            @classmethod
            def define_table_args(cls):
                table_args = super(TestCheckLongConstraintName,
                                   cls).define_table_args()
                return table_args + (
                    CheckConstraint('integer > 0', name=(
                        'long_long_long_long_long_long_long_long_long_long_'
                        'long_long_long_long_long_long_long_long_test')),)

        @register(Model)
        class TestFKTarget:
            integer = Int(primary_key=True)

        @register(Model)
        class TestFK:
            integer = Int(primary_key=True)
            other = Int(
                foreign_key=Model.TestFKTarget.use('integer'))

        @register(Model)
        class TestFK2:
            integer = Int(primary_key=True)
            other = Int(
                foreign_key=Model.TestFKTarget.use('integer').options(
                    ondelete='cascade'))

        @register(Model)
        class TestM2M1:
            idmodel1 = Int(primary_key=True)

        @register(Model)
        class TestM2M2:
            idmodel2 = Int(primary_key=True)
            rel_m2m = Many2Many(label="Rel", model=Model.TestM2M1,
                                join_table='reltable',
                                remote_columns='idmodel1',
                                m2m_remote_columns='idmodel1',
                                local_columns='idmodel2',
                                m2m_local_columns='idmodel2',
                                many2many='rel_m2m_inv')

        EnvironmentManager.set('current_blok', None)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:85,代码来源:test_migration.py

示例15: test_load_without_blok_group

# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import load [as 别名]
 def test_load_without_blok_group(self):
     try:
         BlokManager.load(entry_points=())
         self.fail('No watchdog to load without blok groups')
     except BlokManagerException:
         pass
开发者ID:petrus-v,项目名称:AnyBlok,代码行数:8,代码来源:test_blok.py


注:本文中的anyblok.blok.BlokManager.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。