fixed compilerapp sorting issue, better

This commit is contained in:
mdipierro
2013-10-09 11:31:33 -05:00
parent ddc0fc9949
commit 8fb0b71be6
2 changed files with 31 additions and 27 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.7.2-stable+timestamp.2013.10.09.11.13.44 Version 2.7.2-stable+timestamp.2013.10.09.11.30.04
+30 -26
View File
@@ -512,35 +512,39 @@ def run_models_in(environment):
folder = environment['request'].folder folder = environment['request'].folder
c = environment['request'].controller c = environment['request'].controller
f = environment['request'].function f = environment['request'].function
response = environment['response']
path = pjoin(folder, 'models')
cpath = pjoin(folder, 'compiled') cpath = pjoin(folder, 'compiled')
if os.path.exists(cpath): compiled = os.path.exists(cpath)
for model in sorted(listdir(cpath, '^models[_.].+\.pyc$', 0), if compiled:
model_cmp): models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0),model_cmp)
restricted(read_pyc(model), environment, layer=model)
path = pjoin(cpath, 'models')
models = listdir(path, '^\w+\.pyc$', 0, sort=False)
compiled = True
else: else:
path = pjoin(folder, 'models') models = sorted(listdir(path, '^\w+\.py$', 0, sort=False),model_cmp)
models = listdir(path, '^\w+\.py$', 0, sort=False) n = len(path)+1
compiled = False
n = len(path) + 1 models_to_run = None
for model in models: for model in models:
regex = environment['response'].models_to_run if response.models_to_run != models_to_run:
if isinstance(regex, list): regex = models_to_run = response.models_to_run
regex = re_compile('|'.join(regex)) if isinstance(regex, list):
file = model[n:].replace(os.path.sep, '/').replace('.pyc', '.py') regex = re_compile('|'.join(regex))
if not regex.search(file) and c != 'appadmin': if models_to_run:
continue if compiled:
elif compiled: fname = model[n:-4].replace('.','/')+'.py'
code = read_pyc(model) else:
elif is_gae: fname = model[n:].replace(os.path.sep,'/')
code = getcfs(model, model, if not regex.search(fname) and c != 'appadmin':
lambda: compile2(read_file(model), model)) continue
else: elif compiled:
code = getcfs(model, model, None) code = read_pyc(model)
restricted(code, environment, layer=model) elif is_gae:
code = getcfs(model, model,
lambda: compile2(read_file(model), model))
else:
code = getcfs(model, model, None)
restricted(code, environment, layer=model)
def run_controller_in(controller, function, environment): def run_controller_in(controller, function, environment):