Esempio n. 1
0
 def storeAssociation(self, server_url, association):
   """
   This method puts a C{L{Association <openid.association.Association>}}
   object into storage, retrievable by server URL and handle.
   """
   assoc = Association(url=server_url,
                       handle=association.handle,
                       association=association.serialize())
   assoc.put()
Esempio n. 2
0
 def removeAssociation(self, server_url, handle):
   """
   This method removes the matching association if it's found, and returns
   whether the association was removed or not.
   """
   query = Association.gql('WHERE url = :1 AND handle = :2',
                           server_url, handle)
   return self._delete_first(query)
Esempio n. 3
0
  def cleanupAssociations(self):
    """Remove expired associations from the store.

    This method is not called in the normal operation of the
    library.  It provides a way for store admins to keep
    their storage from filling up with expired data.

    @return: the number of associations expired.
    @returntype: int
    """
    query = Association.gql('WHERE created < :1', self._expiration_datetime())
    return self._cleanup_batch(query)
Esempio n. 4
0
  def getAssociation(self, server_url, handle=None):
    """
    This method returns an C{L{Association <openid.association.Association>}}
    object from storage that matches the server URL and, if specified, handle.
    It returns C{None} if no such association is found or if the matching
    association is expired.

    If no handle is specified, the store may return any association which
    matches the server URL. If multiple associations are valid, the
    recommended return value for this method is the one that will remain valid
    for the longest duration.
    """
    query = Association.all().filter('url', server_url)
    if handle:
      query.filter('handle', handle)

    results = query.fetch(1)
    if results:
      association = OpenIDAssociation.deserialize(results[0].association)
      if association.getExpiresIn() > 0:
        # hasn't expired yet
        return association

    return None