fixed openid store cleanupAssociations
authorRodney Ewing <ewing.rj@gmail.com>
Wed, 26 Jun 2013 19:43:12 +0000 (12:43 -0700)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Wed, 3 Jul 2013 18:49:16 +0000 (13:49 -0500)
mediagoblin/plugins/openid/store.py

index b54cf5c86259628b8862cbcae7edf84cb1d625ed..8f9a7012d7542558ae08ae4f59205c689f9d85c3 100644 (file)
@@ -105,8 +105,6 @@ class SQLAlchemyOpenIDStore(OpenIDStore):
             ononce.save()
             return True
 
-    # Need to test these cleanups, not sure if the expired Association query
-    # will work
     def cleanupNonces(self, _now=None):
         if _now is None:
             _now = int(time.time())
@@ -120,9 +118,10 @@ class SQLAlchemyOpenIDStore(OpenIDStore):
 
     def cleanupAssociations(self):
         now = int(time.time())
-        expired = Association.query.filter(
-            'issued + lifetime' < now)
-        count = expired.count()
-        for each in expired:
-            each.delete()
+        assoc = Association.query.all()
+        count = 0
+        for each in assoc:
+            if (each.lifetime + each.issued) <= now:
+                each.delete()
+                count = count + 1
         return count