Mercurial > moin > 1.9
changeset 5446:709089f30164
moin maint cleansessions: catch KeyErrors for 'expires' and 'user.id' and make the best out of it
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sun, 17 Jan 2010 17:09:49 +0100 |
parents | 2b641be7728c |
children | fed925dfdc0d |
files | MoinMoin/script/maint/cleansessions.py |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/script/maint/cleansessions.py Sun Jan 17 18:30:16 2010 +0300 +++ b/MoinMoin/script/maint/cleansessions.py Sun Jan 17 17:09:49 2010 +0100 @@ -50,7 +50,13 @@ if not self.options.all_sessions: now = time.time() - checks.append(lambda session: session['expires'] < now) + def session_expired(session): + try: + return session['expires'] < now + except KeyError: + # this is likely a pre-1.9.1 session file without expiry + return True # consider it expired + checks.append(session_expired) if self.options.username: u = user.User(request, None, self.options.username) @@ -58,7 +64,12 @@ print 'User "%s" does not exist!' % self.options.username return else: - checks.append(lambda session: session['user.id'] == u.id) + def user_matches(session): + try: + return session['user.id'] == u.id + except KeyError: + return False + checks.append(user_matches) session_service = request.cfg.session_service for sid in session_service.get_all_session_ids(request):