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


Python RegistryManager.add_entry_in_register方法代码示例

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


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

示例1: test_add_entry

# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import add_entry_in_register [as 别名]
    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,代码行数:12,代码来源:test_registry_entry.py

示例2: test_get_entry_properties_in_register

# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import add_entry_in_register [as 别名]
    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,代码行数:14,代码来源:test_registry_entry.py

示例3: test_remove_entry

# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import add_entry_in_register [as 别名]
    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,代码行数:18,代码来源:test_registry_entry.py

示例4: register

# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import add_entry_in_register [as 别名]
    def register(cls, parent, name, cls_, **kwargs):
        """ add new sub registry in the registry

        :param parent: Existing global registry
        :param name: Name of the new registry to add it
        :param cls_: Class Interface to add in registry
        """
        _registryname = parent.__registry_name__ + '.' + name

        if not hasattr(parent, name):
            kwargs['__registry_name__'] = _registryname
            ns = type(name, tuple(), kwargs)
            setattr(parent, name, ns)

        if parent is Declarations:
            return

        RegistryManager.add_entry_in_register(
            cls.__name__, _registryname, cls_, **kwargs)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:21,代码来源:mixin.py

示例5: register

# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import add_entry_in_register [as 别名]
    def register(self, parent, name, cls_, **kwargs):
        """ add new sub registry in the registry

        :param parent: Existing global registry
        :param name: Name of the new registry to add it
        :param cls_: Class Interface to add in registry
        """
        _registryname = parent.__registry_name__ + '.' + name
        if 'tablename' in kwargs:
            tablename = kwargs.pop('tablename')
            if not isinstance(tablename, str):
                tablename = tablename.__tablename__

        elif hasattr(parent, name):
            tablename = getattr(parent, name).__tablename__
        else:
            if parent is Declarations or parent is Declarations.Model:
                tablename = name.lower()
            elif hasattr(parent, '__tablename__'):
                tablename = parent.__tablename__
                tablename += '_' + name.lower()

        if not hasattr(parent, name):
            p = {
                '__tablename__': tablename,
                '__registry_name__': _registryname,
                'use': lambda x: ModelAttribute(_registryname, x),
            }
            ns = type(name, tuple(), p)
            setattr(parent, name, ns)

        if parent is Declarations:
            return

        kwargs['__registry_name__'] = _registryname
        kwargs['__tablename__'] = tablename
        update_factory(kwargs)

        RegistryManager.add_entry_in_register(
            'Model', _registryname, cls_, **kwargs)
        setattr(cls_, '__anyblok_kwargs__', kwargs)
开发者ID:AnyBlok,项目名称:AnyBlok,代码行数:43,代码来源:__init__.py


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