+4
-3
@@ -581,7 +581,7 @@ def run_models_in(environment):
|
|||||||
if not regex.search(fname) and c != 'appadmin':
|
if not regex.search(fname) and c != 'appadmin':
|
||||||
continue
|
continue
|
||||||
elif compiled:
|
elif compiled:
|
||||||
code = read_pyc(model)
|
code = getcfs(model, model, lambda: read_pyc(model))
|
||||||
elif is_gae:
|
elif is_gae:
|
||||||
code = getcfs(model, model,
|
code = getcfs(model, model,
|
||||||
lambda: compile2(read_file(model), model))
|
lambda: compile2(read_file(model), model))
|
||||||
@@ -614,7 +614,8 @@ def run_controller_in(controller, function, environment):
|
|||||||
raise HTTP(404,
|
raise HTTP(404,
|
||||||
rewrite.THREAD_LOCAL.routes.error_message % badf,
|
rewrite.THREAD_LOCAL.routes.error_message % badf,
|
||||||
web2py_error=badf)
|
web2py_error=badf)
|
||||||
restricted(read_pyc(filename), environment, layer=filename)
|
code = getcfs(filename, filename, lambda: read_pyc(filename))
|
||||||
|
restricted(code, environment, layer=filename)
|
||||||
elif function == '_TEST':
|
elif function == '_TEST':
|
||||||
# TESTING: adjust the path to include site packages
|
# TESTING: adjust the path to include site packages
|
||||||
from settings import global_settings
|
from settings import global_settings
|
||||||
@@ -706,7 +707,7 @@ def run_view_in(environment):
|
|||||||
for f in files:
|
for f in files:
|
||||||
compiled = pjoin(path, f)
|
compiled = pjoin(path, f)
|
||||||
if os.path.exists(compiled):
|
if os.path.exists(compiled):
|
||||||
code = read_pyc(compiled)
|
code = getcfs(compiled, compiled, lambda: read_pyc(compiled))
|
||||||
restricted(code, environment, layer=compiled)
|
restricted(code, environment, layer=compiled)
|
||||||
return
|
return
|
||||||
if not os.path.exists(filename) and allow_generic:
|
if not os.path.exists(filename) and allow_generic:
|
||||||
|
|||||||
+1
-1
@@ -199,7 +199,7 @@ class RestrictedError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def compile2(code, layer):
|
def compile2(code, layer):
|
||||||
return compile(code.rstrip(), layer, 'exec')
|
return compile(code, layer, 'exec')
|
||||||
|
|
||||||
|
|
||||||
def restricted(code, environment=None, layer='Unknown'):
|
def restricted(code, environment=None, layer='Unknown'):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import sys
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
from gluon.compileapp import run_controller_in, run_view_in
|
from gluon.compileapp import run_controller_in, run_view_in, compile_application, remove_compiled_application
|
||||||
from gluon.languages import translator
|
from gluon.languages import translator
|
||||||
from gluon.storage import Storage, List
|
from gluon.storage import Storage, List
|
||||||
from gluon import fileutils
|
from gluon import fileutils
|
||||||
@@ -76,7 +76,7 @@ class TestAppAdmin(unittest.TestCase):
|
|||||||
def run_view(self):
|
def run_view(self):
|
||||||
return run_view_in(self.env)
|
return run_view_in(self.env)
|
||||||
|
|
||||||
def test_index(self):
|
def _test_index(self):
|
||||||
result = self.run_function()
|
result = self.run_function()
|
||||||
self.assertTrue('db' in result['databases'])
|
self.assertTrue('db' in result['databases'])
|
||||||
self.env.update(result)
|
self.env.update(result)
|
||||||
@@ -86,6 +86,15 @@ class TestAppAdmin(unittest.TestCase):
|
|||||||
print(e.message)
|
print(e.message)
|
||||||
self.fail('Could not make the view')
|
self.fail('Could not make the view')
|
||||||
|
|
||||||
|
def test_index(self):
|
||||||
|
self._test_index()
|
||||||
|
|
||||||
|
def test_index_compiled(self):
|
||||||
|
appname_path = os.path.join(os.getcwd(), 'applications', 'welcome')
|
||||||
|
compile_application(appname_path)
|
||||||
|
self._test_index()
|
||||||
|
remove_compiled_application(appname_path)
|
||||||
|
|
||||||
def test_select(self):
|
def test_select(self):
|
||||||
request = self.env['request']
|
request = self.env['request']
|
||||||
request.args = List(['db'])
|
request.args = List(['db'])
|
||||||
|
|||||||
Reference in New Issue
Block a user