diff --git a/xblock/field_data.py b/xblock/field_data.py index 1663f7b0a..ee0546c06 100644 --- a/xblock/field_data.py +++ b/xblock/field_data.py @@ -5,7 +5,6 @@ simple. """ import copy - from abc import ABCMeta, abstractmethod from collections import defaultdict @@ -148,7 +147,12 @@ def _field_data(self, block, name): if scope not in self._scope_mappings: raise InvalidScopeError(scope) - return self._scope_mappings[scope] + scope_mapping = self._scope_mappings[scope] + + if scope_mapping is None: + raise InvalidScopeError(scope) + + return scope_mapping def get(self, block, name): return self._field_data(block, name).get(block, name) @@ -161,8 +165,10 @@ def set_many(self, block, update_dict): for key, value in update_dict.items(): update_dicts[self._field_data(block, key)][key] = value for field_data, new_update_dict in update_dicts.items(): - if field_data is not None: # Ignore fields from scopes that are not loaded + try: field_data.set_many(block, new_update_dict) + except InvalidScopeError: + pass # Ignore fields that are not in the scope_mappings def delete(self, block, name): self._field_data(block, name).delete(block, name)