本文整理汇总了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)
示例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')
示例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())
示例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)
示例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)