本文整理汇总了Python中reddit_base.MinimalController类的典型用法代码示例。如果您正苦于以下问题:Python MinimalController类的具体用法?Python MinimalController怎么用?Python MinimalController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MinimalController类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre
def pre(self):
set_extension(request.environ, "json")
MinimalController.pre(self)
require_https()
try:
access_token = OAuth2AccessToken.get_token(self._get_bearer_token())
require(access_token)
require(access_token.check_valid())
c.oauth2_access_token = access_token
account = Account._byID36(access_token.user_id, data=True)
require(account)
require(not account._deleted)
c.oauth_user = account
except RequirementException:
self._auth_error(401, "invalid_token")
handler = self._get_action_handler()
if handler:
oauth2_perms = getattr(handler, "oauth2_perms", None)
if oauth2_perms:
grant = OAuth2Scope(access_token.scope)
if grant.subreddit_only and c.site.name not in grant.subreddits:
self._auth_error(403, "insufficient_scope")
required_scopes = set(oauth2_perms['allowed_scopes'])
if not (grant.scopes >= required_scopes):
self._auth_error(403, "insufficient_scope")
else:
self._auth_error(400, "invalid_request")
示例2: pre
def pre(self):
if g.disallow_db_writes:
abort(403)
set_extension(request.environ, "json")
MinimalController.pre(self)
require_https()
if request.method != "OPTIONS":
c.oauth2_client = self._get_client_auth()
示例3: pre
def pre(self):
MinimalController.pre(self)
# override user loggedin behavior to ensure this page always
# uses the page cache
user = valid_cookie(c.cookies[g.login_cookie].value
if g.login_cookie in c.cookies
else '')
if user:
self.user_is_loggedin = True
示例4: pre
def pre(self):
set_extension(request.environ, "json")
MinimalController.pre(self)
require_https()
try:
access_token = self._get_bearer_token()
require(access_token)
c.oauth2_access_token = access_token
account = Account._byID(access_token.user_id, data=True)
require(account)
require(not account._deleted)
c.oauth_user = account
except RequirementException:
self._auth_error(401, "invalid_token")
handler = self._get_action_handler()
if handler:
oauth2_perms = getattr(handler, "oauth2_perms", None)
if oauth2_perms:
if access_token.scope not in oauth2_perms["allowed_scopes"]:
self._auth_error(403, "insufficient_scope")
else:
self._auth_error(400, "invalid_request")