Skip to content

Commit

Permalink
fix: do not reinitialize the MakoService in the MakoDescriptorSystem (#…
Browse files Browse the repository at this point in the history
…32895)

Without this, Studio raises the "mako.exceptions.TemplateLookupException" with
the "Can't locate template for uri 'discussion/_discussion_inline_studio.html'"
message.
  • Loading branch information
Agrendalath authored Aug 2, 2023
1 parent df63305 commit c3b7b57
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions xmodule/mako_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ def __init__(self, render_template, **kwargs):

self.render_template = render_template

# Add the MakoService to the descriptor system.
# Add the MakoService to the runtime services.
# If it already exists, do not attempt to reinitialize it; otherwise, this could override the `namespace_prefix`
# of the `MakoService`, breaking template rendering in Studio.
#
# This is not needed by most XBlocks, because the MakoService is added to their runtimes.
# However, there are a few cases where the MakoService is not added to the XBlock's
# runtime. Specifically:
# * in the Instructor Dashboard bulk emails tab, when rendering the HtmlBlock for its WYSIWYG editor.
# * during testing, when fetching factory-created blocks.
from common.djangoapps.edxmako.services import MakoService
self._services['mako'] = MakoService()
if 'mako' not in self._services:
from common.djangoapps.edxmako.services import MakoService
self._services['mako'] = MakoService()


class MakoTemplateBlockBase:
Expand Down

0 comments on commit c3b7b57

Please sign in to comment.