From 664ce3bfaea6778c3fbca613ab66da881559f4c3 Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Wed, 26 Jun 2013 12:43:12 -0700 Subject: [PATCH] fixed openid store cleanupAssociations --- mediagoblin/plugins/openid/store.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mediagoblin/plugins/openid/store.py b/mediagoblin/plugins/openid/store.py index b54cf5c8..8f9a7012 100644 --- a/mediagoblin/plugins/openid/store.py +++ b/mediagoblin/plugins/openid/store.py @@ -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