Rename FormConfig.callback to FormConfig.run_script.

pull/7/head
Ferry Boender 9 years ago
parent 01161bcd07
commit 66a7a134ff
  1. 2
      src/formconfig.py
  2. 2
      src/webapp.py
  3. 6
      test/test.py

@ -68,7 +68,7 @@ class FormConfig(object):
form_list.append(form_def)
return form_list
def callback(self, form_name, form_values, stdout=None, stderr=None):
def run_script(self, form_name, form_values, stdout=None, stderr=None):
"""
Perform a callback for the form `form_name`. This calls a script.
`form_values` is a dictionary of validated values as returned by

@ -410,7 +410,7 @@ class ScriptFormWebApp(RequestHandler):
log.info("User: {0}".format(username))
log.info("Variables: {0}".format(dict(form_values.items())))
result = form_config.callback(form_name, form_values, self.wfile,
result = form_config.run_script(form_name, form_values, self.wfile,
self.wfile)
if form_def.output != 'raw':
# Ignore everything if we're doing raw output, since it's the

@ -49,7 +49,7 @@ class FormConfigTestCase(unittest.TestCase):
"""Test a callback that returns output in strings"""
sf = scriptform.ScriptForm('test_formconfig_callback.json')
fc = sf.get_form_config()
res = fc.callback('test_store', {})
res = fc.run_script('test_store', {})
self.assertEquals(res['exitcode'], 33)
self.assertTrue('stdout' in res['stdout'])
self.assertTrue('stderr' in res['stderr'])
@ -60,7 +60,7 @@ class FormConfigTestCase(unittest.TestCase):
fc = sf.get_form_config()
stdout = file('tmp_stdout', 'w+') # can't use StringIO
stderr = file('tmp_stderr', 'w+')
exitcode = fc.callback('test_raw', {}, stdout, stderr)
exitcode = fc.run_script('test_raw', {}, stdout, stderr)
stdout.seek(0)
stderr.seek(0)
self.assertTrue(exitcode == 33)
@ -71,7 +71,7 @@ class FormConfigTestCase(unittest.TestCase):
"""
sf = scriptform.ScriptForm('test_formconfig_callback.json')
fc = sf.get_form_config()
self.assertRaises(ValueError, fc.callback, 'test_raw', {})
self.assertRaises(ValueError, fc.run_script, 'test_raw', {})
class FormDefinitionTest(unittest.TestCase):

Loading…
Cancel
Save