本文整理汇总了Python中gluon.restricted.compile2方法的典型用法代码示例。如果您正苦于以下问题:Python restricted.compile2方法的具体用法?Python restricted.compile2怎么用?Python restricted.compile2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.restricted
的用法示例。
在下文中一共展示了restricted.compile2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_models_in
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import compile2 [as 别名]
def run_models_in(environment):
"""
Runs all models (in the app specified by the current folder)
It tries pre-compiled models first before compiling them.
"""
folder = environment['request'].folder
c = environment['request'].controller
#f = environment['request'].function
response = environment['response']
path = pjoin(folder, 'models')
cpath = pjoin(folder, 'compiled')
compiled = os.path.exists(cpath)
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
models_to_run = None
for model in models:
if response.models_to_run != models_to_run:
regex = models_to_run = response.models_to_run[:]
if isinstance(regex, list):
regex = re_compile('|'.join(regex))
if models_to_run:
if compiled:
n = len(cpath)+8
fname = model[n:-4].replace('.','/')+'.py'
else:
n = len(path)+1
fname = model[n:].replace(os.path.sep,'/')
if not regex.search(fname) and c != 'appadmin':
continue
elif compiled:
code = read_pyc(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)
示例2: run_models_in
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import compile2 [as 别名]
def run_models_in(environment):
"""
Runs all models (in the app specified by the current folder)
It tries pre-compiled models first before compiling them.
"""
request = current.request
folder = request.folder
c = request.controller
# f = environment['request'].function
response = current.response
path = pjoin(folder, 'models')
cpath = pjoin(folder, 'compiled')
compiled = os.path.exists(cpath)
if PY2:
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
else:
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0),
key=lambda f: '{0:03d}'.format(f.count('.')) + f)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False),
key=lambda f: '{0:03d}'.format(f.count(os.path.sep)) + f)
models_to_run = None
for model in models:
if response.models_to_run != models_to_run:
regex = models_to_run = response.models_to_run[:]
if isinstance(regex, list):
regex = re_compile('|'.join(regex))
if models_to_run:
if compiled:
n = len(cpath)+8
fname = model[n:-4].replace('.', '/')+'.py'
else:
n = len(path)+1
fname = model[n:].replace(os.path.sep, '/')
if not regex.search(fname) and c != 'appadmin':
continue
elif compiled:
f = lambda: read_pyc(model)
else:
f = lambda: compile2(read_file(model), model)
ccode = getcfs(model, model, f)
restricted(ccode, environment, layer=model)
示例3: run_models_in
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import compile2 [as 别名]
def run_models_in(environment):
"""
Runs all models (in the app specified by the current folder)
It tries pre-compiled models first before compiling them.
"""
request = current.request
folder = request.folder
c = request.controller
#f = environment['request'].function
response = current.response
path = pjoin(folder, 'models')
cpath = pjoin(folder, 'compiled')
compiled = os.path.exists(cpath)
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
models_to_run = None
for model in models:
if response.models_to_run != models_to_run:
regex = models_to_run = response.models_to_run[:]
if isinstance(regex, list):
regex = re_compile('|'.join(regex))
if models_to_run:
if compiled:
n = len(cpath)+8
fname = model[n:-4].replace('.','/')+'.py'
else:
n = len(path)+1
fname = model[n:].replace(os.path.sep,'/')
if not regex.search(fname) and c != 'appadmin':
continue
elif compiled:
code = read_pyc(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)
示例4: run_models_in
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import compile2 [as 别名]
def run_models_in(environment):
"""
Runs all models (in the app specified by the current folder)
It tries pre-compiled models first before compiling them.
"""
request = current.request
folder = request.folder
c = request.controller
#f = environment['request'].function
response = current.response
path = pjoin(folder, 'models')
cpath = pjoin(folder, 'compiled')
compiled = os.path.exists(cpath)
if PY2:
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
else:
if compiled:
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), key=lambda f: '{0:03d}'.format(f.count('.')) + f)
else:
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), key=lambda f: '{0:03d}'.format(f.count(os.path.sep)) + f)
models_to_run = None
for model in models:
if response.models_to_run != models_to_run:
regex = models_to_run = response.models_to_run[:]
if isinstance(regex, list):
regex = re_compile('|'.join(regex))
if models_to_run:
if compiled:
n = len(cpath)+8
fname = model[n:-4].replace('.','/')+'.py'
else:
n = len(path)+1
fname = model[n:].replace(os.path.sep,'/')
if not regex.search(fname) and c != 'appadmin':
continue
elif compiled:
f = lambda: read_pyc(model)
else:
f = lambda: compile2(read_file(model), model)
ccode = getcfs(model, model, f)
restricted(ccode, environment, layer=model)