cubicweb/pyramid/core.py
changeset 11686 41d4f0f3855c
parent 11631 faf279e33298
child 11701 ca536eec556b
equal deleted inserted replaced
11685:6c263b8091d3 11686:41d4f0f3855c
    18 from cubicweb.pyramid import tools
    18 from cubicweb.pyramid import tools
    19 
    19 
    20 import logging
    20 import logging
    21 
    21 
    22 log = logging.getLogger(__name__)
    22 log = logging.getLogger(__name__)
    23 
       
    24 
       
    25 CW_321 = cubicweb.__pkginfo__.numversion >= (3, 21, 0)
       
    26 
    23 
    27 
    24 
    28 class Connection(cwsession.Connection):
    25 class Connection(cwsession.Connection):
    29     """ A specialised Connection that access the session data through a
    26     """ A specialised Connection that access the session data through a
    30     property.
    27     property.
   245     """
   242     """
   246     session = request.cw_session
   243     session = request.cw_session
   247     if session is None:
   244     if session is None:
   248         return None
   245         return None
   249 
   246 
   250     if CW_321:
   247     cnx = session.new_cnx()
   251         cnx = session.new_cnx()
   248 
   252 
   249     def commit_state(cnx):
   253         def commit_state(cnx):
   250         return cnx.commit_state
   254             return cnx.commit_state
       
   255     else:
       
   256         cnx = repoapi.ClientConnection(session)
       
   257 
       
   258         def commit_state(cnx):
       
   259             return cnx._cnx.commit_state
       
   260 
   251 
   261     def cleanup(request):
   252     def cleanup(request):
   262         try:
   253         try:
   263             if (request.exception is not None and not isinstance(
   254             if (request.exception is not None and not isinstance(
   264                 request.exception, (
   255                 request.exception, (