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


Python association.Association方法代码示例

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


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

示例1: getAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def getAssociation(self, server_url, handle=None):
        """
        Return the association for server_url and handle. If handle is
        not None return the latests associations for that server_url.
        Return None if no association can be found.
        """

        db = self.database
        query = (db.oid_associations.server_url == server_url)
        if handle:
            query &= (db.oid_associations.handle == handle)
        rows = db(query).select(orderby=db.oid_associations.issued)
        keep_assoc, _ = self._removeExpiredAssocations(rows)
        if len(keep_assoc) == 0:
            return None
        else:
            assoc = keep_assoc.pop(
            )  # pop the last one as it should be the latest one
            return Association(assoc['handle'],
                               assoc['secret'],
                               assoc['issued'],
                               assoc['lifetime'],
                               assoc['assoc_type']) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:25,代码来源:openid_auth.py

示例2: storeAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def storeAssociation(self, server_url, association):
        """
        This method will store a MistAssociation object into mongodb after
        creating a MistAssociation with the same values as the Association
        provided.
        Secret will be encoded because it constantly produced errors with
        encoding.
        """

        mist_association = MistAssociation()
        mist_association.assoc_type = association.assoc_type
        mist_association.handle = association.handle.encode('hex')
        mist_association.secret = association.secret.encode('hex')
        mist_association.lifetime = association.lifetime
        mist_association.issued = association.issued
        mist_association.server_url = server_url

        mist_association.save() 
开发者ID:mistio,项目名称:mist.api,代码行数:20,代码来源:oidstore.py

示例3: txn_storeAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def txn_storeAssociation(self, server_url, association):
        """Set the association for the server URL.

        Association -> NoneType
        """
        a = association
        self.db_set_assoc(
            server_url,
            a.handle,
            self.blobEncode(a.secret),
            a.issued,
            a.lifetime,
            a.assoc_type) 
开发者ID:sunqb,项目名称:oa_qian,代码行数:15,代码来源:sqlstore.py

示例4: txn_getAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def txn_getAssociation(self, server_url, handle=None):
        """Get the most recent association that has been set for this
        server URL and handle.

        str -> NoneType or Association
        """
        if handle is not None:
            self.db_get_assoc(server_url, handle)
        else:
            self.db_get_assocs(server_url)

        rows = self.cur.fetchall()
        if len(rows) == 0:
            return None
        else:
            associations = []
            for values in rows:
                assoc = Association(*values)
                assoc.secret = self.blobDecode(assoc.secret)
                if assoc.getExpiresIn() == 0:
                    self.txn_removeAssociation(server_url, assoc.handle)
                else:
                    associations.append((assoc.issued, assoc))

            if associations:
                associations.sort()
                return associations[-1][1]
            else:
                return None 
开发者ID:sunqb,项目名称:oa_qian,代码行数:31,代码来源:sqlstore.py

示例5: getAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def getAssociation(self, server_url, handle=None):
        stored_assocs = OpenIDStore.objects.filter(
            server_url=server_url
        )
        if handle:
            stored_assocs = stored_assocs.filter(handle=handle)

        stored_assocs.order_by('-issued')

        if stored_assocs.count() == 0:
            return None

        return_val = None

        for stored_assoc in stored_assocs:
            assoc = OIDAssociation(
                stored_assoc.handle,
                base64.decodestring(stored_assoc.secret.encode('utf-8')),
                stored_assoc.issued, stored_assoc.lifetime,
                stored_assoc.assoc_type
            )
            # See:
            # necaris/[email protected]
            if hasattr(assoc, 'getExpiresIn'):
                expires_in = assoc.getExpiresIn()
            else:
                expires_in = assoc.expiresIn
            if expires_in == 0:
                stored_assoc.delete()
            else:
                if return_val is None:
                    return_val = assoc

        return return_val 
开发者ID:rtindru,项目名称:django-twilio-tfa,代码行数:36,代码来源:utils.py

示例6: getAssociation

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def getAssociation(self, server_url, handle=None):
        """
        Gets a server url and the handle and finds a matching association that
        has not expired. Expired associations are deleted. The association
        returned is the one with the most recent issuing timestamp.
        """

        query = {'server_url': server_url}
        if handle:
            query.update({'handle': handle.encode('hex')})
        try:
            mist_associations = MistAssociation.objects(**query)
        except me.DoesNotExist:
            mist_associations = []

        filtered_mist_assocs = []

        for assoc in mist_associations:
            if assoc.is_expired():
                assoc.delete()
            else:
                filtered_mist_assocs.append(assoc)

        filtered_mist_assocs = sorted(filtered_mist_assocs,
                                      key=lambda assoc: assoc.issued,
                                      reverse=True)

        if len(filtered_mist_assocs) > 0:
            mist_assoc = filtered_mist_assocs[0]
            association = Association(handle=mist_assoc.handle.decode('hex'),
                                      secret=mist_assoc.secret.decode('hex'),
                                      issued=mist_assoc.issued,
                                      lifetime=mist_assoc.lifetime,
                                      assoc_type=mist_assoc.assoc_type)
            return association

        return None 
开发者ID:mistio,项目名称:mist.api,代码行数:39,代码来源:oidstore.py

示例7: openid_association

# 需要导入模块: from openid import association [as 别名]
# 或者: from openid.association import Association [as 别名]
def openid_association(cls, assoc):
        secret = assoc.secret
        if not isinstance(secret, six.binary_type):
            secret = secret.encode()
        return OpenIdAssociation(assoc.handle, base64.decodestring(secret),
                                 assoc.issued, assoc.lifetime,
                                 assoc.assoc_type) 
开发者ID:python-social-auth,项目名称:social-core,代码行数:9,代码来源:storage.py


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