module_validation module

module_validator(module_class)

This function validates a module class against certain criteria.

Usage is optional, but ensures that the class has the required attributes and methods to function correctly within the framework. It also ensures that the class can use the mixins for implementing the module, see implementations.py to see the mixin classes.

Parameters:

module_class (Any) – The instantiated class to validate.

Raises:

AttributeError – If the class does not have the required attributes.

Return type:

None

Example

>>> from ssb_dash_framework.utils.module_validation import module_validator
>>> class MyModule:
...     _id_number = 0
...     def __init__(self):
...         self.module_number = MyModule._id_number
...         self.module_name = self.__class__.__name__
...         MyModule._id_number += 1
...         self.module_layout = None
...         self.icon = None
...         self.label = None
...         self.module_callbacks = None
...         module_validator(self)
...     def layout(self):
...         pass
...     def module_callbacks(self):
...         pass
>>> my_module = MyModule()

Notes

  • It is highly recommended to add this function in the __init__ method of your module class.

  • This validation works best if used in combination with a test that makes sure the class can be instantiated.