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


Python registry.RegistryManager类代码示例

本文整理汇总了Python中anyblok.registry.RegistryManager的典型用法代码示例。如果您正苦于以下问题:Python RegistryManager类的具体用法?Python RegistryManager怎么用?Python RegistryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: wrapper

        def wrapper(self):
            from anyblok.registry import RegistryManager
            name = self.__name__
            if name in cls.declaration_types:
                raise DeclarationsException(
                    "The declaration type %r is already defined" % name)

            cls.declaration_types[name] = self

            setattr(self, '__registry_name__', name)
            setattr(self, '__declaration_type__', name)
            setattr(cls, name, self)

            if isAnEntry:
                assemble_callback = initialize_callback = None
                if assemble and hasattr(self, assemble):
                    assemble_callback = getattr(self, assemble)

                if initialize and hasattr(self, initialize):
                    initialize_callback = getattr(self, initialize)

                RegistryManager.declare_entry(
                    name, assemble_callback=assemble_callback,
                    initialize_callback=initialize_callback)

            # All declaration type can need to be unload declarated values
            if unload and hasattr(self, unload):
                RegistryManager.declare_unload_callback(
                    name, getattr(self, unload))

            return self
开发者ID:jssuzanne,项目名称:AnyBlok,代码行数:31,代码来源:declarations.py

示例2: unregister

    def unregister(self, entry, cls_):
        """ Remove the Interface from the registry

        :param entry: entry declaration of the model where the ``cls_``
            must be removed
        :param cls_: Class Interface to remove in registry
        """
        RegistryManager.remove_in_register(cls_)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:8,代码来源:__init__.py

示例3: imports

    def imports(self):
        """ Imports modules and / or packages listed in the blok path"""
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager

        RegistryManager.init_blok(self.blok)
        b = BlokManager.get(self.blok)
        b.import_declaration_module()
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:8,代码来源:imp.py

示例4: tearDown

    def tearDown(self):
        """ Clear the registry, unload the blok manager and  drop the database
        """
        if self.registry:
            self.registry.close()

        RegistryManager.clear()
        BlokManager.unload()
        super(DBTestCase, self).tearDown()
开发者ID:petrus-v,项目名称:AnyBlok,代码行数:9,代码来源:testcase.py

示例5: test_add_core

    def test_add_core(self):
        class test:
            pass

        RegistryManager.add_core_in_register('test', test)
        self.assertInCore(test)
        self.assertEqual(
            RegistryManager.has_core_in_register('testCore', 'test'),
            True)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:9,代码来源:test_registry_core.py

示例6: tearDown

 def tearDown(self):
     """ Clear the registry, unload the blok manager and  drop the database
     """
     registry = RegistryManager.get(Configuration.get('db_name'))
     registry.close()
     RegistryManager.clear()
     BlokManager.unload()
     clear_mappers()
     self.__class__.dropdb()
     super(TestBlok, self).tearDown()
开发者ID:AnyBlok,项目名称:AnyBlok_Multi_Engines,代码行数:10,代码来源:test_blok.py

示例7: test_add_entry

    def test_add_entry(self):
        class test:
            pass

        RegistryManager.add_entry_in_register('Other', 'test', test)
        self.assertInEntry('test', test)
        self.assertEqual(
            RegistryManager.has_entry_in_register('testEntry', 'Other',
                                                  'test'),
            True)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:10,代码来源:test_registry_entry.py

示例8: test_update_query

 def test_update_query(self):
     registry = RegistryManager.get(Configuration.get('db_name'))
     registry.upgrade(install=('test-me-blok2',))
     registry.commit()
     self.assertTrue(registry.System.Blok.query().all_name())
     self.assertTrue(registry.System.Blok.query().all())
     registry.close()
     registry = RegistryManager.get(Configuration.get('db_name'))
     self.assertTrue(registry.System.Blok.query().all_name())
     self.assertTrue(registry.System.Blok.query().all())
开发者ID:AnyBlok,项目名称:AnyBlok_Multi_Engines,代码行数:10,代码来源:test_blok.py

示例9: test_get_entry_properties_in_register

    def test_get_entry_properties_in_register(self):
        class test:
            pass

        RegistryManager.add_entry_in_register('Other', 'test', test,
                                              property1='test')
        properties = RegistryManager.get_entry_properties_in_register(
            'Other', 'test')

        hasproperty1 = 'property1' in properties
        self.assertTrue(hasproperty1)
        self.assertEqual(properties['property1'], 'test')
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:12,代码来源:test_registry_entry.py

示例10: test_init_blok

    def test_init_blok(self):
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            self.assertIn(
                core, RegistryManager.loaded_bloks['newblok']['Core'].keys())
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][core], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:15,代码来源:test_registry_manager.py

示例11: register

    def register(self, parent, name, cls_, **kwargs):
        """ Add new sub registry in the registry

        :param parent: Existing declaration
        :param name: Name of the new declaration to add it
        :param cls_: Class Interface to add in the declaration
        """
        if not hasattr(parent, name):
            core = type(name, tuple(), {})
            setattr(parent, name, core)

        if parent == Declarations:
            return

        RegistryManager.add_core_in_register(name, cls_)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:15,代码来源:core.py

示例12: test_add_entry

    def test_add_entry(self):
        RegistryManager.declare_entry('Other')
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for entry in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                      'InstrumentedList'):
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][entry], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Other'],
                         {'registry_names': []})
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:16,代码来源:test_registry_manager.py

示例13: createdb

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,代码行数:32,代码来源:scripts.py

示例14: load_registry

    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,代码行数:34,代码来源:plugins.py

示例15: test_remove_entry

    def test_remove_entry(self):
        class test:
            pass

        def has_test_in_removed():
            core = RegistryManager.loaded_bloks['testEntry']['removed']
            if test in core:
                return True

            return False

        RegistryManager.add_entry_in_register('Other', 'test', test)
        self.assertInEntry('test', test)
        self.assertFalse(has_test_in_removed())
        RegistryManager.remove_in_register(test)
        self.assertTrue(has_test_in_removed())
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:16,代码来源:test_registry_entry.py


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