Changes to handler URL generation
* The LMS now also monkey-patches xmodule.x_module.descriptor_global_handler_url and xmodule.x_module.descriptor_global_local_resource_url so that we can get LMS XBlock URLs from the DescriptorSystem. That functionality is needed in the block transforms collect() phase for certain XModules like Video. For instance, say we want to generate the transcripts URLs. The collect phase is run asynchronously, without a user context. * The URL handler monkey-patching is now done in the startup.py files for LMS and Studio. Studio used to do this in the import of cms/djangoapps/contentstore/views/item.py. This was mostly just because it seemed like a sane and consistent place to put it. * LmsHandlerUrls was removed, its handler_url and local_resource_url methods were moved to be top level functions. The only reason that class existed seems to be to give a place to store course_id state, and that can now be derived from the block location. * To avoid the Module -> Descriptor ProxyAttribute magic that we do (which explodes with an UndefinedContext error because there is no user involved), when examining the block's handler method in handler_url, I made a few changes: ** Check the .__class__ to see if the handler was defined, instead of the block itself. ** The above required me to relax the check for _is_xblock_handler on the function, since that will no longer be defined. 90% of this goes away when we kill XModules and do the refactoring we've wanted to do for a while.
This commit is contained in:
committed by
Nimisha Asthagiri
parent
698e542f6b
commit
9b88bdb072
@@ -36,7 +36,6 @@ from opaque_keys.edx.asides import AsideUsageKeyV1, AsideDefinitionKeyV1
|
||||
from xmodule.exceptions import UndefinedContext
|
||||
import dogstats_wrapper as dog_stats_api
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
XMODULE_METRIC_NAME = 'edxapp.xmodule'
|
||||
@@ -1207,7 +1206,10 @@ class ConfigurableFragmentWrapper(object): # pylint: disable=abstract-method
|
||||
|
||||
# This function exists to give applications (LMS/CMS) a place to monkey-patch until
|
||||
# we can refactor modulestore to split out the FieldData half of its interface from
|
||||
# the Runtime part of its interface. This function matches the Runtime.handler_url interface
|
||||
# the Runtime part of its interface. This function mostly matches the
|
||||
# Runtime.handler_url interface.
|
||||
#
|
||||
# The monkey-patching happens in (lms|cms)/startup.py
|
||||
def descriptor_global_handler_url(block, handler_name, suffix='', query='', thirdparty=False): # pylint: disable=invalid-name, unused-argument
|
||||
"""
|
||||
See :meth:`xblock.runtime.Runtime.handler_url`.
|
||||
@@ -1218,6 +1220,8 @@ def descriptor_global_handler_url(block, handler_name, suffix='', query='', thir
|
||||
# This function exists to give applications (LMS/CMS) a place to monkey-patch until
|
||||
# we can refactor modulestore to split out the FieldData half of its interface from
|
||||
# the Runtime part of its interface. This function matches the Runtime.local_resource_url interface
|
||||
#
|
||||
# The monkey-patching happens in (lms|cms)/startup.py
|
||||
def descriptor_global_local_resource_url(block, uri): # pylint: disable=invalid-name, unused-argument
|
||||
"""
|
||||
See :meth:`xblock.runtime.Runtime.local_resource_url`.
|
||||
@@ -1821,6 +1825,7 @@ class CombinedSystem(object):
|
||||
DescriptorSystem, instead. This allows XModuleDescriptors that are bound as XModules
|
||||
to still function as XModuleDescriptors.
|
||||
"""
|
||||
# First we try a lookup in the module system...
|
||||
try:
|
||||
return getattr(self._module_system, name)
|
||||
except AttributeError:
|
||||
|
||||
Reference in New Issue
Block a user