Merge pull request #2151 from leonelcamara/patch-30

Teach admin how to deal with syntax errors
This commit is contained in:
mdipierro
2019-03-23 22:11:31 -07:00
committed by GitHub

View File

@@ -814,8 +814,11 @@ def edit():
if len(request.args) > 2 and request.args[1] == 'controllers':
controller = (request.args[2])[:-3]
functions = find_exposed_functions(data)
functions = functions and sorted(functions) or []
try:
functions = find_exposed_functions(data)
functions = functions and sorted(functions) or []
except SyntaxError as err:
functions = ['SyntaxError:Line:%d' % err.lineno]
else:
(controller, functions) = (None, None)
@@ -1127,8 +1130,11 @@ def design():
functions = {}
for c in controllers:
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
items = find_exposed_functions(data)
functions[c] = items and sorted(items) or []
try:
items = find_exposed_functions(data)
functions[c] = items and sorted(items) or []
except SyntaxError as err:
functions[c] = ['SyntaxError:Line:%d' % err.lineno]
# Get all views
views = sorted(
@@ -1265,8 +1271,11 @@ def plugin():
functions = {}
for c in controllers:
data = safe_read(apath('%s/controllers/%s' % (app, c), r=request))
items = find_exposed_functions(data)
functions[c] = items and sorted(items) or []
try:
items = find_exposed_functions(data)
functions[c] = items and sorted(items) or []
except SyntaxError as err:
functions[c] = ['SyntaxError:Line:%d' % err.lineno]
# Get all views
views = sorted(