Multifiling
The main advantage of modules in the form of separate directories is the ability to organize the code in a straightforward way. The ModuleExtension
class helps with this (as said before), which allows access to some attributes of the main class outside it (e.g. translations, database), as well as to register handler functions. So, let's create a new extension for our module.
Having created a new file, it is necessary to declare an extension class similar to module, only inherit ModuleExtension
from base.mod_ext
:
Example of creating an extension
After creation, the extension must be registered in the main module class. This is done by overriding the property-method module_extensions
:
Last updated