本文整理匯總了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))