|
|
@ -17,7 +17,6 @@ import BaseHTTPServer |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler |
|
|
|
from SocketServer import ThreadingMixIn |
|
|
|
from SocketServer import ThreadingMixIn |
|
|
|
import cgi |
|
|
|
import cgi |
|
|
|
import re |
|
|
|
|
|
|
|
import datetime |
|
|
|
import datetime |
|
|
|
import subprocess |
|
|
|
import subprocess |
|
|
|
import base64 |
|
|
|
import base64 |
|
|
@ -179,7 +178,6 @@ class ScriptForm: |
|
|
|
path = self.config_file |
|
|
|
path = self.config_file |
|
|
|
config = json.load(file(path, 'r')) |
|
|
|
config = json.load(file(path, 'r')) |
|
|
|
|
|
|
|
|
|
|
|
title = config['title'] |
|
|
|
|
|
|
|
forms = [] |
|
|
|
forms = [] |
|
|
|
callbacks = self.callbacks |
|
|
|
callbacks = self.callbacks |
|
|
|
users = None |
|
|
|
users = None |
|
|
@ -231,6 +229,7 @@ class ScriptForm: |
|
|
|
# same thread. |
|
|
|
# same thread. |
|
|
|
raise SystemExit() |
|
|
|
raise SystemExit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FormConfig: |
|
|
|
class FormConfig: |
|
|
|
""" |
|
|
|
""" |
|
|
|
FormConfig is the in-memory representation of a form configuration JSON |
|
|
|
FormConfig is the in-memory representation of a form configuration JSON |
|
|
@ -562,7 +561,7 @@ class WebAppHandler(BaseHTTPRequestHandler): |
|
|
|
self.send_error(404, "Not found") |
|
|
|
self.send_error(404, "Not found") |
|
|
|
return |
|
|
|
return |
|
|
|
method_cb(**params) |
|
|
|
method_cb(**params) |
|
|
|
except Exception, e: |
|
|
|
except Exception: |
|
|
|
self.send_error(500, "Internal server error") |
|
|
|
self.send_error(500, "Internal server error") |
|
|
|
raise |
|
|
|
raise |
|
|
|
|
|
|
|
|
|
|
@ -711,10 +710,7 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
cols |
|
|
|
cols |
|
|
|
) |
|
|
|
) |
|
|
|
elif field['type'] == 'select': |
|
|
|
elif field['type'] == 'select': |
|
|
|
options = ''.join([ |
|
|
|
options = ''.join([tpl.format(o[0], o[1]) for o in field['options']]) |
|
|
|
tpl.format(o[0], o[1]) for o in field['options'] |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
input = '<select {0} name="{1}">{2}</select>'.format(required, field['name'], options) |
|
|
|
input = '<select {0} name="{1}">{2}</select>'.format(required, field['name'], options) |
|
|
|
else: |
|
|
|
else: |
|
|
|
raise ValueError("Unsupported field type: {0}".format( |
|
|
|
raise ValueError("Unsupported field type: {0}".format( |
|
|
@ -726,12 +722,9 @@ class ScriptFormWebApp(WebAppHandler): |
|
|
|
<p class="form-field-title">{title}</p> |
|
|
|
<p class="form-field-title">{title}</p> |
|
|
|
<p class="form-field-input">{input} <span class="error">{errors}</span></p> |
|
|
|
<p class="form-field-input">{input} <span class="error">{errors}</span></p> |
|
|
|
</li> |
|
|
|
</li> |
|
|
|
'''.format( |
|
|
|
'''.format(title=field['title'], |
|
|
|
title=field['title'], |
|
|
|
|
|
|
|
input=input, |
|
|
|
input=input, |
|
|
|
errors=', '.join(errors) |
|
|
|
errors=', '.join(errors))) |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the user is allowed to access this form. |
|
|
|
# Make sure the user is allowed to access this form. |
|
|
|
form_def = form_config.get_form_def(form_name) |
|
|
|
form_def = form_config.get_form_def(form_name) |
|
|
|