本文整理汇总了Python中models.private_key.PrivateKey.get_oauth方法的典型用法代码示例。如果您正苦于以下问题:Python PrivateKey.get_oauth方法的具体用法?Python PrivateKey.get_oauth怎么用?Python PrivateKey.get_oauth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.private_key.PrivateKey
的用法示例。
在下文中一共展示了PrivateKey.get_oauth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_admin_creates_keys
# 需要导入模块: from models.private_key import PrivateKey [as 别名]
# 或者: from models.private_key.PrivateKey import get_oauth [as 别名]
def test_admin_creates_keys(self):
self.be_admin_user()
get_response = self.testapp.get('/admin')
self.assertEqual(get_response.status_int, 200)
form = get_response.forms["private-key"]
self.assertEqual(form.method, 'POST')
form['oauth_key'] = 'oauth'
form['api_key'] = 'api'
post_response = form.submit()
self.assertEqual(post_response.status_int, 302)
self.assertEqual(post_response.headers['Location'],
'http://localhost:80/admin#tab-private-keys')
self.assertEqual(PrivateKey.get_oauth(), 'oauth')
self.assertEqual(PrivateKey.get_api(), 'api')
示例2: admin
# 需要导入模块: from models.private_key import PrivateKey [as 别名]
# 或者: from models.private_key.PrivateKey import get_oauth [as 别名]
def admin(self):
"""Retrieve a page for performing administrative tasks."""
if not users.get_current_user():
raise cherrypy.HTTPRedirect(users.create_login_url(cherrypy.url()))
elif not users.is_current_user_admin():
raise handlers.http_error(403)
reload_status = PackageVersion.get_reload_status()
if reload_status is not None:
reload_status['percentage'] = '%d%%' % (
100.0 * reload_status['count'] / reload_status['total'])
return handlers.render('admin',
reload_status=reload_status,
private_keys_set=PrivateKey.get_oauth() is not None,
production=handlers.is_production(),
layout={'title': 'Admin Console'})
示例3: requires_oauth_key
# 需要导入模块: from models.private_key import PrivateKey [as 别名]
# 或者: from models.private_key.PrivateKey import get_oauth [as 别名]
def requires_oauth_key(fn, *args, **kwargs):
"""A decorator for actions that require an OAuth2 private key to be set."""
if PrivateKey.get_oauth() is None:
http_error(500, 'No OAuth2 private key set.')
return fn(*args, **kwargs)