From ba7a9437d8451fb78c1b1af26aafa8cb4bea0fc2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 29 Oct 2008 15:09:45 -0700 Subject: [PATCH] "Fix" for occasional "ProgrammingError: no results to fetch" from rows = self.cursor.fetchall() in PostgreSQL session filter. --- controller/Session_storage.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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()