Skip to content

Commit

Permalink
Merge pull request #146 from datacamp/fix-converter-persist
Browse files Browse the repository at this point in the history
fix State.converters persistence issue
  • Loading branch information
Filip Schouwenaars authored Nov 11, 2016
2 parents 4791fe5 + 1528743 commit 65103e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions pythonwhat/State.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class State(object):
after that.
"""
converters = get_manual_converters()

def __init__(self,
student_context=None, solution_context=None,
student_parts=None, solution_parts=None,
Expand Down Expand Up @@ -72,18 +70,12 @@ def __init__(self,

self.highlight = self.student_tree if highlight is None else highlight

self.converters = None
self.converters = get_manual_converters() # accessed only from root state

self.fun_usage = {}
self.manual_sigs = None
self._parser_cache = {}

def get_converters(self):
if self.converters is None:
self.converters = get_manual_converters()

return(self.converters)

def set_used(self, name, stud_index, sol_index):
if name in self.fun_usage.keys():
self.fun_usage[name][sol_index] = stud_index
Expand Down Expand Up @@ -300,4 +292,5 @@ def get_func_map(tree_name, ext_attr, self):

# global setters on State -----------------------------------------------------
def set_converter(key, fundef):
State.converters[key] = fundef
# note that root state is set on the State class in test_exercise
State.root_state.converters[key] = fundef
2 changes: 1 addition & 1 deletion pythonwhat/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __init__(self, info):

def getRepresentation(name, process):
obj_class = getClass(name, process)
converters = pythonwhat.State.State.converters
converters = pythonwhat.State.State.root_state.converters
if obj_class in converters:
repres = convert(name, dill.dumps(converters[obj_class]), process)
if (errored(repres)):
Expand Down

0 comments on commit 65103e6

Please sign in to comment.