本文整理汇总了Python中anyblok.registry.RegistryManager.declare_unload_callback方法的典型用法代码示例。如果您正苦于以下问题:Python RegistryManager.declare_unload_callback方法的具体用法?Python RegistryManager.declare_unload_callback怎么用?Python RegistryManager.declare_unload_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anyblok.registry.RegistryManager
的用法示例。
在下文中一共展示了RegistryManager.declare_unload_callback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapper
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import declare_unload_callback [as 别名]
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