code: def get_object_from_session(entity, key):
      
      def object_from_session_function(service, message):
          """Actual implementation of get_object_from_session function.
  
          :param service: SelenolService object.
          :param message: SelenolMessage request.
          """
          id_ = get_value_from_session(key)(service, message)
          result = service.session.query(entity).get(id_)
          if not result:
              raise SelenolInvalidArgumentException(key, id_)
          return result
      return object_from_session_function
docs: Get an object from the database given an entity and the session key.
  
      :param entity: Class type of the object to retrieve.
      :param key: Array that defines the path of the value inside the message.