Example #1
0
 def call(self, module_name, function_name, *args):
     interpreter = self.interpreter_constructor()
     module = interpreter.bind_module("jpath", module_name)
     function = module.get_function(function_name)
     wrapped_args = [translate.json_to_jpath(v) for v in args]
     result = function.call_with_values(self.make_context(), wrapped_args)
     return translate.jpath_to_json(result)
Example #2
0
 def process_result(self, result, update):
     if update is None:
         update = True
         for value in result:  # result is a Sequence
             if not isinstance(result, d.Update):
                 update = False
                 break
     if update:
         self.datastore.apply_updates(result)
         result = None
     else:
         result = translate.jpath_to_json(result)
     self.datastore.commit()
     return result