# HG changeset patch # User Julien Cristau # Date 1435218692 -7200 # Node ID e8f8a211e5038fe662b2570c0c8f55bfa40bd81b # Parent 78ba3e88a54996af6b5e75b67174263fb152fe3d [core] adjust cnx handling for cubicweb 3.21 Closes #5731814 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__()