Add and clean up __repr__ and __str__ for XModule-related things
This commit is contained in:
@@ -151,12 +151,28 @@ class MongoKeyValueStore(InheritanceKeyValueStore):
|
||||
else:
|
||||
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):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
modulestore: the module store that can be used to retrieve additional modules
|
||||
|
||||
@@ -1596,8 +1596,13 @@ class ModuleSystem(MetricsMixin, ConfigurableFragmentWrapper, Runtime): # pylin
|
||||
"""provide uniform access to attributes (like etree)"""
|
||||
self.__dict__[attr] = val
|
||||
|
||||
def __str__(self):
|
||||
return str(self.__dict__)
|
||||
def __repr__(self):
|
||||
kwargs = self.__dict__.copy()
|
||||
|
||||
# Remove value set transiently by XBlock
|
||||
kwargs.pop('_view_name')
|
||||
|
||||
return "{}{}".format(self.__class__.__name__, kwargs)
|
||||
|
||||
@property
|
||||
def ajax_url(self):
|
||||
|
||||
@@ -33,3 +33,6 @@ class LmsFieldData(SplitFieldData):
|
||||
Scope.user_info: student_data,
|
||||
Scope.preferences: student_data,
|
||||
})
|
||||
|
||||
def __repr__(self):
|
||||
return "LmsFieldData{!r}".format((self._authored_data, self._student_data))
|
||||
|
||||
Reference in New Issue
Block a user