Merge 3.26
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Fri, 10 May 2019 15:58:01 +0200
changeset 12591 f5f83d72ba8d
parent 12590 a5d7fcde74c9 (current diff)
parent 12586 afafc8fd9a45 (diff)
child 12592 7ccf23523670
Merge 3.26 This fixes tests with psycopg2
cubicweb/devtools/testlib.py
cubicweb/pyramid/config.py
cubicweb/server/sources/native.py
--- a/cubicweb/devtools/testlib.py	Wed May 08 21:37:13 2019 +0200
+++ b/cubicweb/devtools/testlib.py	Fri May 10 15:58:01 2019 +0200
@@ -446,10 +446,7 @@
                               reverse_primary_email=user)
         user.cw_clear_relation_cache('in_group', 'subject')
         if commit:
-            try:
-                req.commit()  # req is a session
-            except AttributeError:
-                req.cnx.commit()
+            getattr(req, 'cnx', req).commit()
         return user
 
     # other utilities #########################################################
--- a/cubicweb/server/sources/native.py	Wed May 08 21:37:13 2019 +0200
+++ b/cubicweb/server/sources/native.py	Fri May 10 15:58:01 2019 +0200
@@ -690,7 +690,8 @@
                         self.debug('transaction has been rolled back')
                 except Exception:
                     pass
-            if ex.__class__.__name__ == 'IntegrityError':
+            if any(cls.__name__ for cls in ex.__class__.__mro__
+                   if cls.__name__ == 'IntegrityError'):
                 # need string comparison because of various backends
                 for arg in ex.args:
                     # postgres, sqlserver