xblock-utils

raw JSON →
4.0.0 verified Fri May 01 auth: no python

Various utilities for developing XBlocks for the Open edX platform. Version 4.0.0 is the latest. Release cadence is irregular, with minor updates every few months.

pip install xblock-utils
error ImportError: cannot import name 'StudioEditableXBlockMixin' from 'xblockutils'
cause The import path changed from top-level to submodule in an older version.
fix
Use: from xblockutils.studio_editable import StudioEditableXBlockMixin
error ModuleNotFoundError: No module named 'xblockutils'
cause xblock-utils is not installed.
fix
Run: pip install xblock-utils
error AttributeError: 'MyXBlock' object has no attribute 'editable_fields'
cause You must set editable_fields on the class when using StudioEditableXBlockMixin.
fix
Add editable_fields = ['field1', 'field2'] to your XBlock class.
breaking Version 3.0.0 dropped Python 2.7 support and switched to GitHub Actions CI. Ensure your XBlock code is Python 3 only.
fix Update your XBlock to be Python 3 compatible.
breaking Version 3.1.0 requires edx-platform 'Nutmeg' or newer because it uses the mako service. Older platforms will break.
fix Upgrade your Open edX instance to Nutmeg or later.
deprecated The 'XBlockWithMixins' class is deprecated and will be removed in a future release. Use standard Python inheritance instead.
fix Inherit from the specific mixin classes directly.
gotcha When using StudioContainerXBlockMixin, you must also inherit from XBlock and call the parent class' methods correctly. Omitting super() calls can lead to broken runtime behavior.
fix Always include super().workbench_scenarios() and other overridden methods.

Define an XBlock with studio-editable fields using StudioEditableXBlockMixin.

from xblock.core import XBlock
from xblockutils.studio_editable import StudioEditableXBlockMixin

class MyXBlock(StudioEditableXBlockMixin, XBlock):
    display_name = 'My Editable Block'
    editable_fields = ['display_name']