From 897e2ab95da7cd914cbec558d7adfa745590ca36 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Fri, 16 Sep 2016 16:28:20 +0200 Subject: [PATCH] caching read_pyc for controllers and models --- gluon/compileapp.py | 5 +++-- gluon/restricted.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gluon/compileapp.py b/gluon/compileapp.py index 0ee9c18c..70f924b1 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -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 diff --git a/gluon/restricted.py b/gluon/restricted.py index c67bcbf4..c0725a15 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -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'):