caching read_pyc for controllers and models

This commit is contained in:
ilvalle
2016-09-16 16:28:20 +02:00
parent b84b47dad2
commit 897e2ab95d
2 changed files with 4 additions and 3 deletions

View File

@@ -581,7 +581,7 @@ def run_models_in(environment):
if not regex.search(fname) and c != 'appadmin':
continue
elif compiled:
code = read_pyc(model)
code = getcfs(model, model, lambda: read_pyc(model))
elif is_gae:
code = getcfs(model, model,
lambda: compile2(read_file(model), model))
@@ -614,7 +614,8 @@ def run_controller_in(controller, function, environment):
raise HTTP(404,
rewrite.THREAD_LOCAL.routes.error_message % 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':
# TESTING: adjust the path to include site packages
from settings import global_settings

View File

@@ -199,7 +199,7 @@ class RestrictedError(Exception):
def compile2(code, layer):
return compile(code.rstrip(), layer, 'exec')
return compile(code, layer, 'exec')
def restricted(code, environment=None, layer='Unknown'):