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