Skip to content

Commit

Permalink
Support python3-openid last changes on Association class
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Oct 23, 2013
1 parent 061024a commit 5fbdfe8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions social/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ def removeAssociation(self, server_url, handle):
if associations_ids:
self.assoc.remove(associations_ids)

def expiresIn(self, assoc):
if hasattr(assoc, 'getExpiresIn'):
return assoc.getExpiresIn()
else: # python3-openid 3.0.2
return assoc.expiresIn

def getAssociation(self, server_url, handle=None):
"""Return stored assocition"""
oid_associations = self.assoc.oids(server_url, handle)
associations = [association
for assoc_id, association in oid_associations
if association.getExpiresIn() > 0]
expired = [assoc_id for assoc_id, association in oid_associations
if association.getExpiresIn() == 0]
associations, expired = [], []
for assoc_id, association in self.assoc.oids(server_url, handle):
expires = self.expiresIn(association)
if expires > 0:
associations.append(association)
elif expires == 0:
expired.append(association)

if expired: # clear expired associations
self.assoc.remove(expired)
Expand Down

0 comments on commit 5fbdfe8

Please sign in to comment.