hooks.py 694 Bytes
Newer Older
Charles Hebert's avatar
0.1.0  
Charles Hebert committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
""" this module contains server side hooks for cleaning forgotpwd table
"""

from datetime import datetime
from cubicweb.server import hooksmanager

class ServerStartupHook(hooksmanager.Hook):
    """ Delete old revocation key
    """
    events = ('server_startup',)
    def call(self, repo):
        def cleaning_revocation_key(repo):
            session = repo.internal_session()
            session.execute('DELETE Fpasswd F WHERE F revocation_date < %(date)s', {'date': datetime.now()})
            session.commit()
            session.close()
17
18
        # revocation keu must be deleted
        cleaning_revocation_key(repo)
Charles Hebert's avatar
0.1.0  
Charles Hebert committed
19
        repo.looping_task(60 * 60, cleaning_revocation_key, repo)