Module¶
Modules are registered at the module registry, managed by an application object.
See Application.Modules
for more details.
Module can be loaded by ASAB and typically provides one or more Service
objects.
Structure¶
Recommended structure of the ASAB module:
mymodule/
__init__.py
myservice.py
Content of the __init__.py:
import asab
from .myservice import MyService
# Extend ASAB configuration defaults
asab.Config.add_defaults({
'mymodule': {
'foo': 'bar'
}
})
class MyModule(asab.Module):
def __init__(self, app):
super().__init__(app)
self.service = MyService(app, "MyService")
And this is how the module is loaded:
from mymodule import MyModule
app.add_module(MyModule)
For more details see Application.add_module
.