[pyramid] Don't use unsafe_cnx_context_manager for write queries
we may have clumsy error that hide previous problems on attempting to commit the transaction.
Closes #16753531
--- a/cubicweb/pyramid/session.py Wed Dec 14 08:37:11 2016 +0100
+++ b/cubicweb/pyramid/session.py Mon Dec 19 17:22:48 2016 +0100
@@ -28,6 +28,8 @@
If request has an attached connection, its security will be deactived in the context manager's
scope, else a new internal connection is returned.
+
+ This should be used for read-only queries, not if you intend to commit/rollback some data.
"""
cnx = request.cw_cnx
if cnx is None:
@@ -134,7 +136,7 @@
data = Binary(pickle.dumps(dict(self)))
sessioneid = self.sessioneid
- with unsafe_cnx_context_manager(self.request) as cnx:
+ with self.request.registry['cubicweb.repository'].internal_cnx() as cnx:
if not sessioneid:
session = cnx.create_entity(
'CWSession', cwsessiondata=data)