diff -r 78ba3e88a549 -r e8f8a211e503 pyramid_cubicweb/core.py --- a/pyramid_cubicweb/core.py Tue Jun 30 11:15:03 2015 +0200 +++ b/pyramid_cubicweb/core.py Thu Jun 25 09:51:32 2015 +0200 @@ -243,19 +243,21 @@ session = request.cw_session if session is None: return None - cnx = repoapi.ClientConnection(session) + cnx = session.new_cnx() def cleanup(request): - if (request.exception is not None and not isinstance( - request.exception, ( - httpexceptions.HTTPSuccessful, - httpexceptions.HTTPRedirection))): - cnx.rollback() - elif cnx._cnx.commit_state == 'uncommitable': - cnx.rollback() - else: - cnx.commit() - cnx.__exit__(None, None, None) + try: + if (request.exception is not None and not isinstance( + request.exception, ( + httpexceptions.HTTPSuccessful, + httpexceptions.HTTPRedirection))): + cnx.rollback() + elif cnx.commit_state == 'uncommitable': + cnx.rollback() + else: + cnx.commit() + finally: + cnx.__exit__(None, None, None) request.add_finished_callback(cleanup) cnx.__enter__()