当前位置: 首页>>代码示例>>Python>>正文


Python restricted.compile2方法代码示例

本文整理汇总了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) 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:43,代码来源:compileapp.py

示例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) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:51,代码来源:compileapp.py

示例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) 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:44,代码来源:compileapp.py

示例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) 
开发者ID:rekall-innovations,项目名称:rekall-agent-server,代码行数:49,代码来源:compileapp.py


注:本文中的gluon.restricted.compile2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。