本文整理汇总了Python中gluon.restricted.RestrictedError方法的典型用法代码示例。如果您正苦于以下问题:Python restricted.RestrictedError方法的具体用法?Python restricted.RestrictedError怎么用?Python restricted.RestrictedError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.restricted
的用法示例。
在下文中一共展示了restricted.RestrictedError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app_compile
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def app_compile(app, request, skip_failed_views=False):
"""Compiles the application
Args:
app(str): application name
request: the global request object
Returns:
None if everything went ok, traceback text if errors are found
"""
from gluon.compileapp import compile_application, remove_compiled_application
folder = apath(app, request)
try:
failed_views = compile_application(folder, skip_failed_views)
return failed_views
except (Exception, RestrictedError):
tb = traceback.format_exc()
remove_compiled_application(folder)
return tb
示例2: app_compile
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def app_compile(app, request, skip_failed_views=False):
"""Compiles the application
Args:
app(str): application name
request: the global request object
Returns:
None if everything went ok, traceback text if errors are found
"""
from compileapp import compile_application, remove_compiled_application
folder = apath(app, request)
try:
failed_views = compile_application(folder, skip_failed_views)
return failed_views
except (Exception, RestrictedError):
tb = traceback.format_exc(sys.exc_info)
remove_compiled_application(folder)
return tb
示例3: app_compile
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def app_compile(app, request, skip_failed_views=False):
"""Compiles the application
Args:
app(str): application name
request: the global request object
Returns:
None if everything went ok, traceback text if errors are found
"""
from compileapp import compile_application, remove_compiled_application
folder = apath(app, request)
try:
failed_views = compile_application(folder, skip_failed_views)
return failed_views
except (Exception, RestrictedError):
tb = traceback.format_exc()
remove_compiled_application(folder)
return tb
示例4: app_compile
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def app_compile(app, request):
"""Compiles the application
Args:
app(str): application name
request: the global request object
Returns:
None if everything went ok, traceback text if errors are found
"""
from compileapp import compile_application, remove_compiled_application
folder = apath(app, request)
try:
compile_application(folder)
return None
except (Exception, RestrictedError):
tb = traceback.format_exc(sys.exc_info)
remove_compiled_application(folder)
return tb
示例5: RestrictedError
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def RestrictedError(a, b, c):
logging.error(str(a) + ':' + str(b) + ':' + str(c))
return RuntimeError
示例6: _raise_error
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def _raise_error(self, message='', text=None):
"""
Raises an error using itself as the filename and textual content.
"""
raise RestrictedError(self.name, text or self.text, message)
示例7: parse_template
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def parse_template(filename,
path='views/',
context=dict(),
lexers={},
delimiters=('{{', '}}')
):
"""
Args:
filename: can be a view filename in the views folder or an input stream
path: is the path of a views folder
context: is a dictionary of symbols used to render the template
lexers: dict of custom lexers to use
delimiters: opening and closing tags
"""
# First, if we have a str try to open the file
if isinstance(filename, str):
fname = os.path.join(path, filename)
try:
with open(fname, 'rb') as fp:
text = fp.read()
except IOError:
raise RestrictedError(filename, '', 'Unable to find the file')
else:
text = filename.read()
text = to_native(text)
# Use the file contents to get a parsed template and return it.
return str(TemplateParser(text, context=context, path=path, lexers=lexers, delimiters=delimiters))
示例8: parse_template
# 需要导入模块: from gluon import restricted [as 别名]
# 或者: from gluon.restricted import RestrictedError [as 别名]
def parse_template(filename,
path='views/',
context=dict(),
lexers={},
delimiters=('{{', '}}')
):
"""
Args:
filename: can be a view filename in the views folder or an input stream
path: is the path of a views folder
context: is a dictionary of symbols used to render the template
lexers: dict of custom lexers to use
delimiters: opening and closing tags
"""
# First, if we have a str try to open the file
if isinstance(filename, str):
try:
fp = open(os.path.join(path, filename), 'rb')
text = fp.read()
fp.close()
except IOError:
raise RestrictedError(filename, '', 'Unable to find the file')
else:
text = filename.read()
# Use the file contents to get a parsed template and return it.
return str(TemplateParser(text, context=context, path=path, lexers=lexers, delimiters=delimiters))