def source(self, cls):
"""
A decorator to mark package source modules
It would register all the methods of the class marked by @handler
with the dispatcher.
"""
try:
from pomu.source.base import BaseSource
except ImportError: #circular import
return cls
if cls == BaseSource:
return cls
self.backends[cls.__name__] = cls
for m, obj in inspect.getmembers(cls):
if isinstance(obj, self.handler._handler):
self.register_package_handler(cls, obj.handler, obj.priority)
return cls
评论列表
文章目录