refactor: deprecate node_path attribute of ModuleSystem (#30447)
The node_path attribute & constructor argument of the ModuleSystem is deprecated without any replacement service or fallback as there doesn't seem to be any core blocks using it. It also removes the references to node_path from the LMS settings, the LoncapaModuleSystem and the XBlock runtime shim. Co-authored-by: Agrendalath <piotr@surowiec.it>
This commit is contained in:
@@ -104,7 +104,6 @@ class LoncapaSystem(object):
|
||||
get_python_lib_zip,
|
||||
DEBUG,
|
||||
i18n,
|
||||
node_path,
|
||||
render_template,
|
||||
resources_fs,
|
||||
seed, # Why do we do this if we have self.seed?
|
||||
@@ -119,7 +118,6 @@ class LoncapaSystem(object):
|
||||
self.get_python_lib_zip = get_python_lib_zip
|
||||
self.DEBUG = DEBUG # pylint: disable=invalid-name
|
||||
self.i18n = i18n
|
||||
self.node_path = node_path
|
||||
self.render_template = render_template
|
||||
self.resources_fs = resources_fs
|
||||
self.seed = seed # Why do we do this if we have self.seed?
|
||||
|
||||
@@ -73,7 +73,6 @@ def test_capa_system(render_template=None):
|
||||
get_python_lib_zip=lambda: None,
|
||||
DEBUG=True,
|
||||
i18n=gettext.NullTranslations(),
|
||||
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
|
||||
render_template=render_template or tst_render_template,
|
||||
resources_fs=fs.osfs.OSFS(os.path.join(TEST_DIR, "test_files")),
|
||||
seed=0,
|
||||
|
||||
@@ -618,7 +618,6 @@ class ProblemBlock(
|
||||
get_python_lib_zip=None,
|
||||
DEBUG=None,
|
||||
i18n=self.runtime.service(self, "i18n"),
|
||||
node_path=None,
|
||||
render_template=None,
|
||||
resources_fs=self.runtime.resources_fs,
|
||||
seed=None,
|
||||
@@ -680,7 +679,6 @@ class ProblemBlock(
|
||||
get_python_lib_zip=(lambda: get_python_lib_zip(contentstore, self.runtime.course_id)),
|
||||
DEBUG=None,
|
||||
i18n=self.runtime.service(self, "i18n"),
|
||||
node_path=None,
|
||||
render_template=None,
|
||||
resources_fs=self.runtime.resources_fs,
|
||||
seed=1,
|
||||
@@ -829,7 +827,6 @@ class ProblemBlock(
|
||||
get_python_lib_zip=sandbox_service.get_python_lib_zip,
|
||||
DEBUG=self.runtime.DEBUG,
|
||||
i18n=self.runtime.service(self, "i18n"),
|
||||
node_path=self.runtime.node_path,
|
||||
render_template=self.runtime.service(self, 'mako').render_template,
|
||||
resources_fs=self.runtime.resources_fs,
|
||||
seed=seed, # Why do we do this if we have self.seed?
|
||||
|
||||
@@ -168,7 +168,6 @@ def get_test_system(
|
||||
),
|
||||
'replace_urls': replace_url_service
|
||||
},
|
||||
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
|
||||
course_id=course_id,
|
||||
error_descriptor_class=ErrorBlock,
|
||||
descriptor_runtime=descriptor_system,
|
||||
|
||||
@@ -1609,6 +1609,18 @@ class ModuleSystemShim:
|
||||
)
|
||||
return self.resources_fs
|
||||
|
||||
@property
|
||||
def node_path(self):
|
||||
"""
|
||||
Path to node_modules. Doesn't seem to be used by any ModuleSystem dependent core XBlock anymore.
|
||||
|
||||
Deprecated.
|
||||
"""
|
||||
warnings.warn(
|
||||
'node_path is deprecated. Please use other methods of finding the node_modules location.',
|
||||
DeprecationWarning, stacklevel=3
|
||||
)
|
||||
|
||||
|
||||
class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, ModuleSystemShim, Runtime):
|
||||
"""
|
||||
@@ -1626,7 +1638,7 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, ModuleSystemShim,
|
||||
def __init__(
|
||||
self, static_url, track_function, get_module,
|
||||
descriptor_runtime, debug=False, hostname="", publish=None,
|
||||
node_path="", course_id=None, error_descriptor_class=None,
|
||||
course_id=None, error_descriptor_class=None,
|
||||
field_data=None, rebind_noauth_module_to_user=None,
|
||||
**kwargs):
|
||||
"""
|
||||
@@ -1668,7 +1680,6 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, ModuleSystemShim,
|
||||
self.get_module = get_module
|
||||
self.DEBUG = self.debug = debug
|
||||
self.HOSTNAME = self.hostname = hostname
|
||||
self.node_path = node_path
|
||||
self.course_id = course_id
|
||||
|
||||
if publish:
|
||||
|
||||
@@ -731,7 +731,6 @@ def get_module_system_for_user(
|
||||
user=user,
|
||||
debug=settings.DEBUG,
|
||||
hostname=settings.SITE_NAME,
|
||||
node_path=settings.NODE_PATH,
|
||||
publish=publish,
|
||||
course_id=course_id,
|
||||
# TODO: When we merge the descriptor and module systems, we can stop reaching into the mixologist (cpennington)
|
||||
|
||||
@@ -1087,16 +1087,6 @@ NODE_MODULES_ROOT = REPO_ROOT / "node_modules"
|
||||
|
||||
DATA_DIR = COURSES_ROOT
|
||||
|
||||
# For Node.js
|
||||
|
||||
system_node_path = os.environ.get("NODE_PATH", NODE_MODULES_ROOT)
|
||||
|
||||
node_paths = [
|
||||
COMMON_ROOT / "static/js/vendor",
|
||||
system_node_path,
|
||||
]
|
||||
NODE_PATH = ':'.join(node_paths)
|
||||
|
||||
# For geolocation ip database
|
||||
GEOIP_PATH = REPO_ROOT / "common/static/data/geoip/GeoLite2-Country.mmdb"
|
||||
# Where to look for a status message
|
||||
|
||||
@@ -145,16 +145,6 @@ class RuntimeShim:
|
||||
)
|
||||
return self.resources_fs
|
||||
|
||||
@property
|
||||
def node_path(self):
|
||||
"""
|
||||
Get the path to Node.js
|
||||
|
||||
Seems only to be used by capa. Remove this if capa can be refactored.
|
||||
"""
|
||||
# TODO: Refactor capa to access this directly, don't bother the runtime. Then remove it from here.
|
||||
return getattr(settings, 'NODE_PATH', None) # Only defined in the LMS
|
||||
|
||||
def render_template(self, template_name, dictionary, namespace='main'):
|
||||
"""
|
||||
Render a mako template
|
||||
|
||||
Reference in New Issue
Block a user