Make it possible to use PluginLoader without store
[cascardo/ipsilon.git] / ipsilon / providers / openid / store.py
index 0eaee0a..bf2898c 100644 (file)
@@ -65,28 +65,35 @@ class OpenIDStore(Store, OpenIDStoreInterface):
 
         return True
 
+    def _cleanup(self):
+        res1 = self.cleanupNonces()
+        res2 = self.cleanupAssociations()
+        return res1 + res2
+
     def cleanupNonces(self):
         nonces = self.get_unique_data('nonce')
+        cleaned = 0
         for iden in nonces:
             if nonces[iden]['timestamp'] < (time() - NonceSKEW):
+                cleaned += 1
                 self.del_unique_data('nonce', iden)
+        return cleaned
 
     def cleanupAssociations(self):
         assocs = self.get_unique_data('association')
+        cleaned = 0
         for iden in assocs:
             if ((int(assocs[iden]['issued']) + int(assocs[iden]['lifetime']))
                     < time()):
+                cleaned += 1
                 self.del_unique_data('association', iden)
+        return cleaned
 
     def _initialize_schema(self):
         q = self._query(self._db, 'association', UNIQUE_DATA_TABLE,
                         trans=False)
         q.create()
         q._con.close()  # pylint: disable=protected-access
-        q = self._query(self._db, 'openid_extensions', OPTIONS_TABLE,
-                        trans=False)
-        q.create()
-        q._con.close()  # pylint: disable=protected-access
 
     def _upgrade_schema(self, old_version):
         if old_version == 1: