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


Python Client.resource_owner方法代码示例

本文整理汇总了Python中models.Client.resource_owner方法的典型用法代码示例。如果您正苦于以下问题:Python Client.resource_owner方法的具体用法?Python Client.resource_owner怎么用?Python Client.resource_owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Client的用法示例。


在下文中一共展示了Client.resource_owner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import resource_owner [as 别名]
 def register(self):
     if request.method == u'POST':
         client_key = self.generate_client_key()
         secret = self.generate_client_secret()
         # TODO: input sanitisation?
         name = request.form.get(u"name")
         description = request.form.get(u"description")
         callback = request.form.get(u"callback")
         pubkey = request.form.get(u"pubkey")
         # TODO: redirect?
         # TODO: pubkey upload
         # TODO: csrf
         info = {
             u"client_key": client_key,
             u"name": name,
             u"description": description,
             u"secret": secret,
             u"pubkey": pubkey
         }
         client = Client(**info)
         client.callbacks.append(Callback(callback))
         client.resource_owner = g.user
         db_session.add(client)
         db_session.commit()
         return render_template(u"client.html", **info)
     else:
         clients = g.user.clients
         return render_template(u"register.html", clients=clients)
开发者ID:felixhummel,项目名称:flask-oauthprovider,代码行数:30,代码来源:provider.py

示例2: register

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import resource_owner [as 别名]
    def register(self):
        """Registers a new client (app)."""
        if request.method == u'POST':
            client_key = self.generate_client_key()
            secret = self.generate_client_secret()

            name = request.form.get(u"name")
            description = request.form.get(u"description")
            callback = request.form.get(u"callback")
            pubkey = request.form.get(u"pubkey")

            # Validoitaan syötteet:
            params = [name, description, callback, pubkey]
            if any(not param for param in params):
                flash("Please fill all fields.")
                return redirect(url_for("register"))

            for param in params:
                if len(param) < 5:
                    flash("Input too short: " + param)
                    return redirect(url_for("register"))
                if len(param) > 60:
                    flash("Input too long: ")
                    return redirect(url_for("register"))

            if not callback.startswith("http://"):
                flash("Invalid callback url: " + callback)
                return redirect(url_for("register"))

            info = {
                u"client_key": client_key,
                u"name": name,
                u"description": description,
                u"secret": secret,
                u"pubkey": pubkey
            }
            cb = Callback(callback=callback)
            cb_key = cb.put()
            client = Client(**info)
            client.callbacks.append(cb_key)
            client.resource_owner = g.user.key
            client.put()
            return render_template(u"client.html", **info)
        else:
            clients = Client.query(Client.resource_owner == g.user.key)
            return render_template(u"register.html", clients=clients)
开发者ID:epiphone,项目名称:pucktracker,代码行数:48,代码来源:provider.py


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