event_routing_backends.processors.openedx_filters package#
Submodules#
event_routing_backends.processors.openedx_filters.decorators module#
Decorators that helps to implement the Processor filter functionality.
- event_routing_backends.processors.openedx_filters.decorators.openedx_filter(filter_type)#
This decorator allows to implement the ProcessorBaseFilter on multiple class methods and intends to modify the returned value from methods like get_actor or get_objects in cases where the standard output doesn’t satisfy the implementation requirements.
- Parameters
filter_type – String that defines the filter_type attribute of ProcessorBaseFilter, this allows to identify the configuration setting.
Example
Decorate your method:
@openedx_filter(filter_type=”this.will.be.the.filter.key”) def get_object(self):
…
Set the openedx filter config in your environment variables.
- OPEN_EDX_FILTERS_CONFIG = {
- “this.will.be.the.filter.key”: {
“pipeline”: [“path.to.an.external.pipeline.step”], “fail_silently”: False,
}
}
More details about filters openedx/openedx-filters
event_routing_backends.processors.openedx_filters.exceptions module#
Custom processors exceptions thrown by filters.
- exception event_routing_backends.processors.openedx_filters.exceptions.InvalidFilterType(message='', redirect_to=None, status_code=None, **kwargs)#
Bases:
openedx_filters.exceptions.OpenEdxFilterException
Exception that indicates that the attribute filter_type has not been set property.
event_routing_backends.processors.openedx_filters.filters module#
Processors filters, this file aims to contain all the filters that could modify the standard transformer results by implementing external pipeline steps.
- class event_routing_backends.processors.openedx_filters.filters.ProcessorBaseFilter#
Bases:
openedx_filters.tooling.OpenEdxPublicFilter
This is a general filter class that applies the open edx filter in multiple scenarios, its functionality is limited to one input one output therefore this only can be applied in method that returns a unique value.
- classmethod generate_dynamic_filter(filter_type)#
This generates a sub class of ProcessorBaseFilter with the filter_type attribute.
- Parameters
filter_type – String the defines the filter key on the OPEN_EDX_FILTERS_CONFIG section
- Returns
This new class includes the filter_type attribute.
- Return type
ProcessorBaseFilter sub-class
- classmethod run_filter(transformer, result)#
Executes a filter after validating the right class configuration.
- Parameters
transformer – XApiTransformer instance.
result – Result to be modified or extended.
- Returns
- This value comes from the dictionary returned by run_pipeline and will vary
depends on the implemented pipelines.
- Return type
result
- Raises
InvalidFilterType – if the ProcessorBaseFilter is used instead of a dynamic filter.