Commit 4ef53135 by Calen Pennington

Add and clean up __repr__ and __str__ for XModule-related things

parent 8fbb6432
...@@ -151,12 +151,28 @@ class MongoKeyValueStore(InheritanceKeyValueStore): ...@@ -151,12 +151,28 @@ class MongoKeyValueStore(InheritanceKeyValueStore):
else: else:
return False return False
def __repr__(self):
return "MongoKeyValueStore{!r}<{!r}, {!r}>".format(
(self._data, self._parent, self._children, self._metadata),
self._fields,
self.inherited_settings
)
class CachingDescriptorSystem(MakoDescriptorSystem, EditInfoRuntimeMixin): class CachingDescriptorSystem(MakoDescriptorSystem, EditInfoRuntimeMixin):
""" """
A system that has a cache of module json that it will use to load modules A system that has a cache of module json that it will use to load modules
from, with a backup of calling to the underlying modulestore for more data from, with a backup of calling to the underlying modulestore for more data
""" """
def __repr__(self):
return "CachingDescriptorSystem{!r}".format((
self.modulestore,
unicode(self.course_id),
[unicode(key) for key in self.module_data.keys()],
self.default_class,
[unicode(key) for key in self.cached_metadata.keys()],
))
def __init__(self, modulestore, course_key, module_data, default_class, cached_metadata, **kwargs): def __init__(self, modulestore, course_key, module_data, default_class, cached_metadata, **kwargs):
""" """
modulestore: the module store that can be used to retrieve additional modules modulestore: the module store that can be used to retrieve additional modules
......
...@@ -1596,8 +1596,13 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # pylin ...@@ -1596,8 +1596,13 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # pylin
"""provide uniform access to attributes (like etree)""" """provide uniform access to attributes (like etree)"""
self.__dict__[attr] = val self.__dict__[attr] = val
def __str__(self): def __repr__(self):
return str(self.__dict__) kwargs = self.__dict__.copy()
# Remove value set transiently by XBlock
kwargs.pop('_view_name')
return "{}{}".format(self.__class__.__name__, kwargs)
@property @property
def ajax_url(self): def ajax_url(self):
......
...@@ -33,3 +33,6 @@ class LmsFieldData(SplitFieldData): ...@@ -33,3 +33,6 @@ class LmsFieldData(SplitFieldData):
Scope.user_info: student_data, Scope.user_info: student_data,
Scope.preferences: student_data, Scope.preferences: student_data,
}) })
def __repr__(self):
return "LmsFieldData{!r}".format((self._authored_data, self._student_data))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment