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


Python Client.query方法代码示例

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


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

示例1: validate_access_token

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_access_token(self, client_key, resource_owner_key):
        token = None
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = AccessToken.query(
                AccessToken.client == client.key,
                AccessToken.token == resource_owner_key).get()

        return token is not None
开发者ID:epiphone,项目名称:pucktracker,代码行数:12,代码来源:provider.py

示例2: validate_verifier

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_verifier(self, client_key, resource_owner_key, verifier):
        token = None
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = RequestToken.query(
                RequestToken.client == client.key,
                RequestToken.token == resource_owner_key,
                RequestToken.verifier == verifier).get()

        return token is not None
开发者ID:epiphone,项目名称:pucktracker,代码行数:13,代码来源:provider.py

示例3: save_request_token

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def save_request_token(self, client_key, request_token, callback,
            realm=None, secret=None):
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = RequestToken(
                token=request_token,
                callback=callback,
                secret=secret,
                realm=realm,
                client=client.key)
            token.put()
开发者ID:epiphone,项目名称:pucktracker,代码行数:14,代码来源:provider.py

示例4: get_access_token_secret

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def get_access_token_secret(self, client_key, resource_owner_key):
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = AccessToken.query(
                AccessToken.client == client.key,
                AccessToken.token == resource_owner_key).get()

            if token:
                return token.secret

        return None
开发者ID:epiphone,项目名称:pucktracker,代码行数:14,代码来源:provider.py

示例5: get_request_token_secret

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def get_request_token_secret(self, client_key, resource_owner_key):
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = RequestToken.query(
                RequestToken.client == client.key,
                RequestToken.token == resource_owner_key).get()

            if token:
                return token.secret

        return None
开发者ID:epiphone,项目名称:pucktracker,代码行数:14,代码来源:provider.py

示例6: get_realm

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def get_realm(self, client_key, request_token):
        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = RequestToken.query(
                RequestToken.token == request_token,
                RequestToken.client == client.key).get()

            if token:
                return token.realm

        return None
开发者ID:epiphone,项目名称:pucktracker,代码行数:14,代码来源:provider.py

示例7: save_access_token

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def save_access_token(self, client_key, access_token, request_token,
            secret=None):
        client = Client.query(Client.client_key == client_key).get()
        req_token = RequestToken.query(
            RequestToken.token == request_token).get()

        if client and req_token:
            token = AccessToken(
                token=access_token,
                secret=secret,
                client=client.key,
                resource_owner=req_token.resource_owner,
                realm=req_token.realm)
            token.put()
开发者ID:epiphone,项目名称:pucktracker,代码行数:16,代码来源:provider.py

示例8: validate_request_token

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_request_token(self, client_key, resource_owner_key):
        token = None
        if client_key:
            client = Client.query(Client.client_key == client_key).get()

            if client:
                token = RequestToken.query(
                    RequestToken.token == resource_owner_key,
                    RequestToken.client == client.key).get()
        else:
            token = RequestToken.query(
                RequestToken.token == resource_owner_key).get()

        return token is not None
开发者ID:epiphone,项目名称:pucktracker,代码行数:16,代码来源:provider.py

示例9: validate_redirect_uri

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_redirect_uri(self, client_key, redirect_uri=None):
        try:
            cbs = Client.query(Client.client_key == client_key).get().callbacks
            if redirect_uri in (x.callback for x in ndb.get_multi(cbs)):
                return True

            elif len(cbs) == 1 and redirect_uri is None:
                return True

            else:
                return False

        except AttributeError:  # Clientiä ei löytynyt
            return False
开发者ID:epiphone,项目名称:pucktracker,代码行数:16,代码来源:provider.py

示例10: validate_realm

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_realm(self, client_key, access_token, uri=None, required_realm=None):
        if not required_realm:
            return True

        client = Client.query(Client.client_key == client_key).get()

        if client:
            token = AccessToken.query(
                AccessToken.token == access_token,
                AccessToken.client == client.key).get()

            if token:
                return token.realm in required_realm

        return False
开发者ID:epiphone,项目名称:pucktracker,代码行数:17,代码来源:provider.py

示例11: register

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [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

示例12: save_timestamp_and_nonce

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def save_timestamp_and_nonce(self, client_key, timestamp, nonce,
            request_token=None, access_token=None):
        client = Client.query(Client.client_key == client_key).get()

        if client:
            nonce = Nonce(
                nonce=nonce,
                timestamp=timestamp,
                client=client.key)

            if request_token:
                req_token = RequestToken.query(
                    RequestToken.token == request_token).get()
                nonce.request_token = req_token.key

            if access_token:
                token = AccessToken.query(
                    AccessToken.token == access_token).get()
                nonce.access_token = token.key

            nonce.put()
开发者ID:epiphone,项目名称:pucktracker,代码行数:23,代码来源:provider.py

示例13: validate_timestamp_and_nonce

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def validate_timestamp_and_nonce(self, client_key, timestamp, nonce,
            request_token=None, access_token=None):
        token = True
        req_token = True
        client = Client.query(Client.client_key == client_key).get()

        if client:
            nonce = Nonce.query(
                Nonce.nonce == nonce,
                Nonce.timestamp == timestamp,
                Nonce.client == client.key).get()

            if nonce:
                if request_token:
                    req_token = nonce.request_token.get()
                    if req_token and req_token.token == request_token:
                        return False
                if access_token:
                    token = nonce.access_token.get()
                    if token and token.token == access_token:
                        return False
            return True
        else:
            return False
开发者ID:epiphone,项目名称:pucktracker,代码行数:26,代码来源:provider.py

示例14: get_rsa_key

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def get_rsa_key(self, client_key):
        try:
            return Client.query(Client.client_key == client_key).get().pubkey

        except AttributeError:
            return None
开发者ID:epiphone,项目名称:pucktracker,代码行数:8,代码来源:provider.py

示例15: get_client_secret

# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import query [as 别名]
    def get_client_secret(self, client_key):
        try:
            return Client.query(Client.client_key == client_key).get().secret

        except AttributeError:
            return None
开发者ID:epiphone,项目名称:pucktracker,代码行数:8,代码来源:provider.py


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