1212
1313Key Concepts:
1414- Filters receive data and return modified data
15- - They run at specific pipeline steps during platform operations
15+ - They run at specific pipeline steps during platform operations
1616- Filters can halt execution by raising exceptions
1717- Multiple filters can be chained together in a pipeline
1818- Filters should be lightweight and handle errors gracefully
@@ -56,18 +56,17 @@ class ChangeCourseAboutPageUrl(PipelineStep):
5656 This filter hooks into the course about page URL rendering process.
5757 Register it for the filter: org.openedx.learning.course.about.render.started.v1
5858
59- Registration Example (in settings/common.py):
60- ```python
61- def plugin_settings(settings):
62- settings.OPEN_EDX_FILTERS_CONFIG = {
63- "org.openedx.learning.course.about.render.started.v1": {
64- "pipeline": [
65- "sample_plugin.pipeline.ChangeCourseAboutPageUrl"
66- ],
67- "fail_silently": False,
59+ Registration Example (in settings/common.py)::
60+
61+ def plugin_settings(settings):
62+ settings.OPEN_EDX_FILTERS_CONFIG = {
63+ "org.openedx.learning.course.about.render.started.v1": {
64+ "pipeline": [
65+ "sample_plugin.pipeline.ChangeCourseAboutPageUrl"
66+ ],
67+ "fail_silently": False,
68+ }
6869 }
69- }
70- ```
7170
7271 Filter Documentation:
7372 - Available Filters: https://docs.openedx.org/projects/openedx-filters/en/latest/reference/filters.html
@@ -100,7 +99,7 @@ def run_filter(self, url, org, **kwargs):
10099
101100 Raises:
102101 FilterException: If processing should be halted
103-
102+
104103 Filter Requirements:
105104 - Must return dictionary with keys matching input parameters
106105 - Return None to skip this filter (let other filters run)
@@ -121,14 +120,14 @@ def run_filter(self, url, org, **kwargs):
121120 match = re .search (pattern , url )
122121 if match :
123122 course_id = match .group ('course_id' )
124-
123+
125124 # Example: Redirect to external marketing site
126125 new_url = f"https://example.com/new_about_page/{ course_id } "
127-
126+
128127 logger .debug (
129128 f"Redirecting course about page for { course_id } from { url } to { new_url } "
130129 )
131-
130+
132131 # Return modified data
133132 return {"url" : new_url , "org" : org }
134133
@@ -137,17 +136,17 @@ def run_filter(self, url, org, **kwargs):
137136 return {"url" : url , "org" : org }
138137
139138 # Alternative patterns for different business logic:
140-
139+
141140 # Organization-based routing:
142141 # if org == "special_org":
143142 # new_url = f"https://special-site.com/courses/{course_id}"
144143 # return {"url": new_url, "org": org}
145-
144+
146145 # Course type-based routing:
147146 # if "MicroMasters" in course_id:
148147 # new_url = f"https://micromasters.example.com/{course_id}"
149148 # return {"url": new_url, "org": org}
150-
149+
151150 # A/B testing implementation:
152151 # import random
153152 # if random.choice([True, False]):
0 commit comments