本文整理汇总了Python中bottle.PluginError方法的典型用法代码示例。如果您正苦于以下问题:Python bottle.PluginError方法的具体用法?Python bottle.PluginError怎么用?Python bottle.PluginError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle
的用法示例。
在下文中一共展示了bottle.PluginError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def setup(self, app):
""" Make sure that other installed plugins don't affect the same
keyword argument and check if metadata is available."""
for other in app.plugins:
if not isinstance(other, AuthPlugin):
continue
if other.keyword == self.keyword:
raise bottle.PluginError("Found another auth plugin "
"with conflicting settings ("
"non-unique keyword).")
示例2: setup
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def setup(self, app):
''' Make sure that other installed plugins don't affect the same
keyword argument.'''
for other in app.plugins:
if not isinstance(other, self.__class__):
continue
if other.keyword == self.keyword:
raise PluginError("Found another AuthorizationHeaderBottlePlugin plugin with "
"conflicting settings (non-unique keyword).")
示例3: setup
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def setup(self, app):
''' Make sure that other installed plugins don't affect the same
keyword argument.'''
for other in app.plugins:
if hasattr(other, "keyword"):
if other.keyword == self.keyword:
raise PluginError("Found another BSONBottlePlugin plugin with "\
"conflicting settings (non-unique keyword).")
示例4: testAddOtherPluginWithSameKeywork
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def testAddOtherPluginWithSameKeywork(self):
app = Mock()
bad_plugin = Mock()
bad_plugin.keyword = "bson_data"
app.plugins = set([bad_plugin])
self.assertRaises(PluginError, self.plugin.setup, app)
示例5: __init__
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def __init__(self, domain, locale_dir, lang_code=None, default='en', keyword='i18n'):
self.domain = domain
if locale_dir is None:
raise PluginError('No locale directory found, please assign a right one.')
self._locale_dir = locale_dir
self._locales = self._get_languages(self._locale_dir)
self._default = default
self._lang_code = lang_code
self._cache = {}
self._apps = []
self._keyword = keyword
示例6: setup
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def setup(self, app): # pragma: no cover
"""Make sure that other installed plugins don't affect the same
keyword argument and check if metadata is available.
"""
if self.login_enable:
# Route a login handler in bottle.py app instance.
@app.post(self.auth_endpoint)
def auth_handler():
try:
token, expires = self.provider.authenticate(bottle.request)
return {"token": token.decode("utf-8"), "expires": str(expires)}
except JWTAuthError as error:
return {"AuthError": error.args[0]}
except JWTBackendError:
return {"AuthBackendError": "Try later or contact admin!"}
for other in app.plugins:
if not isinstance(other, JWTProviderPlugin):
continue
if other.keyword == self.keyword:
raise bottle.PluginError("Found another JWT plugin "
"with conflicting settings ("
"non-unique keyword).")
示例7: setup
# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import PluginError [as 别名]
def setup(self, app):
""" Make sure that other installed plugins don't affect the same
keyword argument and check if metadata is available."""
for other in app.plugins:
if not isinstance(other, BeakerPlugin):
continue
if other.keyword == self.keyword:
raise bottle.PluginError("Found another beaker plugin "
"with conflicting settings ("
"non-unique keyword).")