Skip to content

Commit

Permalink
docs: document XBLOCK_MIXINS and XBLOCK_EXTRA_MIXINS
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Apr 17, 2024
1 parent 28a105b commit 38d350f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
17 changes: 14 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,16 +995,27 @@
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.x_module import XModuleMixin

# These are the Mixins that should be added to every XBlock.
# This should be moved into an XBlock Runtime/Application object
# once the responsibility of XBlock creation is moved out of modulestore - cpennington
# These are the Mixins that will be added to every Blocklike upon instantiation.
# DO NOT EXPAND THIS LIST!! We want it eventually to be EMPTY. Why? Because dynamically adding functions/behaviors to
# objects at runtime is confusing for both developers and static tooling (pylint/mypy). Instead...
# - to add special Blocklike behaviors just for your site: override `XBLOCK_EXTRA_MIXINS` with your own XBlockMixins.
# - to add new functionality to all Blocklikes: add it to the base Blocklike class in the core openedx/XBlock repo.
XBLOCK_MIXINS = (
# TODO: For each of these, either
# (a) merge their functionality into the base Blocklike class, or
# (b) refactor their functionality out of the Blocklike objects and into the edx-platform block runtimes.
LmsBlockMixin,
InheritanceMixin,
XModuleMixin,
EditInfoMixin,
AuthoringMixin,
)

# .. setting_name: XBLOCK_EXTRA_MIXINS
# .. setting_default: ()
# .. setting_description: Custom mixins that will be dynamically added to every XBlock and XBlockAside instance.
# These can be classes or dotted-path references to classes.
# For example: `XBLOCK_EXTRA_MIXINS = ('my_custom_package.my_module.MyCustomMixin',)`
XBLOCK_EXTRA_MIXINS = ()

# Paths to wrapper methods which should be applied to every XBlock's FieldData.
Expand Down
24 changes: 20 additions & 4 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,12 +1640,28 @@ def _make_mako_template_dirs(settings):
from xmodule.modulestore.inheritance import InheritanceMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
from xmodule.x_module import XModuleMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position

# These are the Mixins that should be added to every XBlock.
# This should be moved into an XBlock Runtime/Application object
# once the responsibility of XBlock creation is moved out of modulestore - cpennington
XBLOCK_MIXINS = (LmsBlockMixin, InheritanceMixin, XModuleMixin, EditInfoMixin)
# These are the Mixins that will be added to every Blocklike upon instantiation.
# DO NOT EXPAND THIS LIST!! We want it eventually to be EMPTY. Why? Because dynamically adding functions/behaviors to
# objects at runtime is confusing for both developers and static tooling (pylint/mypy). Instead...
# - to add special Blocklike behaviors just for your site: override `XBLOCK_EXTRA_MIXINS` with your own XBlockMixins.
# - to add new functionality to all Blocklikes: add it to the base Blocklike class in the core openedx/XBlock repo.
XBLOCK_MIXINS = (
# TODO: For each of these, either
# (a) merge their functionality into the base Blocklike class, or
# (b) refactor their functionality out of the Blocklike objects and into the edx-platform block runtimes.
LmsBlockMixin,
InheritanceMixin,
XModuleMixin,
EditInfoMixin,
)
if SkillTaggingMixin:
XBLOCK_MIXINS += (SkillTaggingMixin,)

# .. setting_name: XBLOCK_EXTRA_MIXINS
# .. setting_default: ()
# .. setting_description: Custom mixins that will be dynamically added to every XBlock and XBlockAside instance.
# These can be classes or dotted-path references to classes.
# For example: `XBLOCK_EXTRA_MIXINS = ('my_custom_package.my_module.MyCustomMixin',)`
XBLOCK_EXTRA_MIXINS = ()

# .. setting_name: XBLOCK_FIELD_DATA_WRAPPERS
Expand Down

0 comments on commit 38d350f

Please sign in to comment.