From db2edc779b1a6bcdf2e5a04f384f1251f84ea7b9 Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Fri, 8 Nov 2019 11:23:44 +0000 Subject: [PATCH] publish muk_session_store - 11.0 --- muk_session_store/__manifest__.py | 2 +- muk_session_store/store/postgres.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/muk_session_store/__manifest__.py b/muk_session_store/__manifest__.py index 3e563a0..3be8535 100644 --- a/muk_session_store/__manifest__.py +++ b/muk_session_store/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Session Store", "summary": """Session Store Options""", - "version": "11.0.1.0.3", + "version": "11.0.1.0.4", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", diff --git a/muk_session_store/store/postgres.py b/muk_session_store/store/postgres.py index 84da35c..480e109 100644 --- a/muk_session_store/store/postgres.py +++ b/muk_session_store/store/postgres.py @@ -23,11 +23,12 @@ import psycopg2 import functools from contextlib import closing +from datetime import datetime from werkzeug.contrib.sessions import SessionStore from odoo.sql_db import db_connect -from odoo.tools import config +from odoo.tools import config, DEFAULT_SERVER_DATETIME_FORMAT _logger = logging.getLogger(__name__) @@ -107,6 +108,10 @@ class PostgresSessionStore(SessionStore): """, [sid]) try: payload, write_date = self.cursor.fetchone() + if isinstance(write_date, str): + write_date = datetime.strptime( + write_date, DEFAULT_SERVER_DATETIME_FORMAT + ) if write_date.date() != datetime.today().date(): self.cursor.execute(""" UPDATE sessions @@ -114,7 +119,8 @@ class PostgresSessionStore(SessionStore): WHERE sid=%s; """, [sid]) return self.session_class(json.loads(payload), sid, False) - except Exception: + except Exception as error: + _logger.exception("PostgresSessionStore", exc_info=error) return self.session_class({}, sid, False) @ensure_cursor