diff --git a/controller/Session_storage.py b/controller/Session_storage.py index 73c0ff1..9b3505f 100644 --- a/controller/Session_storage.py +++ b/controller/Session_storage.py @@ -1,4 +1,5 @@ import cherrypy +from psycopg2 import ProgrammingError from cherrypy.filters.sessionfilter import PostgreSQLStorage @@ -12,6 +13,13 @@ class Session_storage( PostgreSQLStorage ): self.db = cherrypy.root.database.get_connection() self.cursor = self.db.cursor() + def load( self, *args, **kwargs ): + try: + PostgreSQLStorage.load( self, *args, **kwargs ) + # catch "ProgrammingError: no results to fetch" from self.cursor.fetchall() + except ProgrammingError: + return None + def save( self, *args, **kwargs ): PostgreSQLStorage.save( self, *args, **kwargs ) self.db.commit()