[web session] ProgrammingError may be raised, we should catch it (closes #1980076) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 04 Oct 2011 13:59:12 +0200
branchstable
changeset 7909 71c70bf482cf
parent 7908 faec7589f742
child 7911 5ab88d05083f
[web session] ProgrammingError may be raised, we should catch it (closes #1980076)
dbapi.py
web/views/sessions.py
--- a/dbapi.py	Tue Oct 04 13:58:57 2011 +0200
+++ b/dbapi.py	Tue Oct 04 13:59:12 2011 +0200
@@ -254,6 +254,8 @@
     def anonymous_session(self):
         return not self.cnx or self.cnx.anonymous_connection
 
+    def __repr__(self):
+        return '<DBAPISession %r>' % self.sessionid
 
 class DBAPIRequest(RequestSessionBase):
 
--- a/web/views/sessions.py	Tue Oct 04 13:58:57 2011 +0200
+++ b/web/views/sessions.py	Tue Oct 04 13:59:12 2011 +0200
@@ -25,7 +25,7 @@
                       BadConnectionId)
 from cubicweb.web import InvalidSession, Redirect
 from cubicweb.web.application import AbstractSessionManager
-from cubicweb.dbapi import DBAPISession
+from cubicweb.dbapi import ProgrammingError, DBAPISession
 
 
 class InMemoryRepositorySessionManager(AbstractSessionManager):
@@ -133,6 +133,6 @@
         if session.cnx:
             try:
                 session.cnx.close()
-            except BadConnectionId: # expired on the repository side
+            except (ProgrammingError, BadConnectionId): # expired on the repository side
                 pass
             session.cnx = None