Commit 5a6040c3 authored by Julien Cristau's avatar Julien Cristau
Browse files

[hooks] use internal_cnx instead of internal_session

New in cubicweb 3.19
parent 70a8b5152aad
...@@ -20,7 +20,7 @@ classifiers = [ ...@@ -20,7 +20,7 @@ classifiers = [
'Programming Language :: JavaScript', 'Programming Language :: JavaScript',
] ]
__depends__ = {'cubicweb': '>= 3.15.0', __depends__ = {'cubicweb': '>= 3.19.0',
'pycrypto': None, 'pycrypto': None,
'PIL': None, 'PIL': None,
} }
......
...@@ -8,7 +8,7 @@ Homepage: http://www.cubicweb.org/project/cubicweb-forgotpwd ...@@ -8,7 +8,7 @@ Homepage: http://www.cubicweb.org/project/cubicweb-forgotpwd
Package: cubicweb-forgotpwd Package: cubicweb-forgotpwd
Architecture: all Architecture: all
Depends: cubicweb-common (>= 3.9.0), python-crypto, python-imaging Depends: cubicweb-common (>= 3.19.0), python-crypto, python-imaging
Description: password recovery component for the CubicWeb framework Description: password recovery component for the CubicWeb framework
This CubicWeb component provides password recovery functionnality. This CubicWeb component provides password recovery functionnality.
. .
......
...@@ -25,13 +25,10 @@ class ServerStartupHook(hook.Hook): ...@@ -25,13 +25,10 @@ class ServerStartupHook(hook.Hook):
# XXX use named args and inner functions to avoid referencing globals # XXX use named args and inner functions to avoid referencing globals
# which may cause reloading pb # which may cause reloading pb
def cleaning_revocation_key(repo, now=datetime.now): def cleaning_revocation_key(repo, now=datetime.now):
session = repo.internal_session() with repo.internal_cnx() as cnx:
try: cnx.execute('DELETE Fpasswd F WHERE F revocation_date < %(date)s',
session.execute('DELETE Fpasswd F WHERE F revocation_date < %(date)s',
{'date': now()}) {'date': now()})
session.commit() cnx.commit()
finally:
session.close()
# run looping task often enough to purge pwd-reset requests # run looping task often enough to purge pwd-reset requests
limit = self.repo.vreg.config['revocation-limit'] * 60 limit = self.repo.vreg.config['revocation-limit'] * 60
self.repo.looping_task(limit, cleaning_revocation_key, self.repo) self.repo.looping_task(limit, cleaning_revocation_key, self.repo)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment