from xblock.runtime import KeyValueStore, InvalidScopeError


class SessionKeyValueStore(KeyValueStore):
    def __init__(self, request, model_data):
        self._model_data = model_data
        self._session = request.session

    def get(self, key):
        try:
            return self._model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            return self._session[tuple(key)]

    def set(self, key, value):
        try:
            self._model_data[key.field_name] = value
        except (KeyError, InvalidScopeError):
            self._session[tuple(key)] = value

    def delete(self, key):
        try:
            del self._model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            del self._session[tuple(key)]

    def has(self, key):
        return key in self._model_data or key in self._session

from xblock.runtime import KeyValueStore, InvalidScopeError


class SessionKeyValueStore(KeyValueStore):
    def __init__(self, request, descriptor_model_data):
        self._descriptor_model_data = descriptor_model_data
        self._session = request.session

    def get(self, key):
        try:
            return self._descriptor_model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            return self._session[tuple(key)]

    def set(self, key, value):
        try:
            self._descriptor_model_data[key.field_name] = value
        except (KeyError, InvalidScopeError):
            self._session[tuple(key)] = value

    def delete(self, key):
        try:
            del self._descriptor_model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            del self._session[tuple(key)]

    def has(self, key):
        return key in self._descriptor_model_data or key in self._session

Make SessionKeyValueStore variable names clearer
Make SessionKeyValueStore variable names clearer

  from xblock.runtime import KeyValueStore, InvalidScopeError
  
  
  class SessionKeyValueStore(KeyValueStore):
-     def __init__(self, request, model_data):
+     def __init__(self, request, descriptor_model_data):
-         self._model_data = model_data
+         self._descriptor_model_data = descriptor_model_data
          self._session = request.session
  
      def get(self, key):
          try:
-             return self._model_data[key.field_name]
+             return self._descriptor_model_data[key.field_name]
          except (KeyError, InvalidScopeError):
              return self._session[tuple(key)]
  
      def set(self, key, value):
          try:
-             self._model_data[key.field_name] = value
+             self._descriptor_model_data[key.field_name] = value
          except (KeyError, InvalidScopeError):
              self._session[tuple(key)] = value
  
      def delete(self, key):
          try:
-             del self._model_data[key.field_name]
+             del self._descriptor_model_data[key.field_name]
          except (KeyError, InvalidScopeError):
              del self._session[tuple(key)]
  
      def has(self, key):
-         return key in self._model_data or key in self._session
+         return key in self._descriptor_model_data or key in self._session
  
Make SessionKeyValueStore variable names clearer
## Code Before:
from xblock.runtime import KeyValueStore, InvalidScopeError


class SessionKeyValueStore(KeyValueStore):
    def __init__(self, request, model_data):
        self._model_data = model_data
        self._session = request.session

    def get(self, key):
        try:
            return self._model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            return self._session[tuple(key)]

    def set(self, key, value):
        try:
            self._model_data[key.field_name] = value
        except (KeyError, InvalidScopeError):
            self._session[tuple(key)] = value

    def delete(self, key):
        try:
            del self._model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            del self._session[tuple(key)]

    def has(self, key):
        return key in self._model_data or key in self._session

## Instruction:
Make SessionKeyValueStore variable names clearer
## Code After:
from xblock.runtime import KeyValueStore, InvalidScopeError


class SessionKeyValueStore(KeyValueStore):
    def __init__(self, request, descriptor_model_data):
        self._descriptor_model_data = descriptor_model_data
        self._session = request.session

    def get(self, key):
        try:
            return self._descriptor_model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            return self._session[tuple(key)]

    def set(self, key, value):
        try:
            self._descriptor_model_data[key.field_name] = value
        except (KeyError, InvalidScopeError):
            self._session[tuple(key)] = value

    def delete(self, key):
        try:
            del self._descriptor_model_data[key.field_name]
        except (KeyError, InvalidScopeError):
            del self._session[tuple(key)]

    def has(self, key):
        return key in self._descriptor_model_data or key in self._session
