当前位置: 首页>>代码示例>>Python>>正文


Python reddit_base.MinimalController类代码示例

本文整理汇总了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")
开发者ID:1900,项目名称:reddit,代码行数:29,代码来源:oauth2.py

示例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()
开发者ID:AHAMED750,项目名称:reddit,代码行数:9,代码来源:oauth2.py

示例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
开发者ID:git001,项目名称:reddit,代码行数:9,代码来源:buttons.py

示例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")
开发者ID:FesterCluck,项目名称:reddit,代码行数:24,代码来源:oauth2.py


注:本文中的reddit_base.MinimalController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。