cubicweb/web/application.py
changeset 12542 85194bd49119
parent 12503 b01dd0ef43aa
child 12567 26744ad37953
equal deleted inserted replaced
12541:bbbccb0b3a66 12542:85194bd49119
    21 import contextlib
    21 import contextlib
    22 import json
    22 import json
    23 import sys
    23 import sys
    24 from time import clock, time
    24 from time import clock, time
    25 from contextlib import contextmanager
    25 from contextlib import contextmanager
    26 from warnings import warn
       
    27 
    26 
    28 from six import text_type, binary_type
    27 from six import text_type, binary_type
    29 from six.moves import http_client
    28 from six.moves import http_client
    30 
    29 
    31 from rql import BadRQLQuery
    30 from rql import BadRQLQuery
    35     CW_EVENT_MANAGER, ValidationError, Unauthorized, Forbidden,
    34     CW_EVENT_MANAGER, ValidationError, Unauthorized, Forbidden,
    36     AuthenticationError, NoSelectableObject)
    35     AuthenticationError, NoSelectableObject)
    37 from cubicweb.repoapi import anonymous_cnx
    36 from cubicweb.repoapi import anonymous_cnx
    38 from cubicweb.web import cors
    37 from cubicweb.web import cors
    39 from cubicweb.web import (
    38 from cubicweb.web import (
    40     LOGGER, StatusResponse, DirectResponse, Redirect, NotFound, LogOut,
    39     LOGGER, DirectResponse, Redirect, NotFound, LogOut,
    41     RemoteCallFailed, InvalidSession, RequestError, PublishException)
    40     RemoteCallFailed, InvalidSession, RequestError, PublishException)
    42 
    41 
    43 # make session manager available through a global variable so the debug view can
    42 # make session manager available through a global variable so the debug view can
    44 # print information about web session
    43 # print information about web session
    45 SESSION_MANAGER = None
    44 SESSION_MANAGER = None
   355                 result = controller.publish(rset=rset)
   354                 result = controller.publish(rset=rset)
   356             except cors.CORSPreflight:
   355             except cors.CORSPreflight:
   357                 # Return directly an empty 200
   356                 # Return directly an empty 200
   358                 req.status_out = 200
   357                 req.status_out = 200
   359                 result = b''
   358                 result = b''
   360             except StatusResponse as ex:
       
   361                 warn('[3.16] StatusResponse is deprecated use req.status_out',
       
   362                      DeprecationWarning, stacklevel=2)
       
   363                 result = ex.content
       
   364                 req.status_out = ex.status
       
   365             except Redirect as ex:
   359             except Redirect as ex:
   366                 # Redirect may be raised by edit controller when everything went
   360                 # Redirect may be raised by edit controller when everything went
   367                 # fine, so attempt to commit
   361                 # fine, so attempt to commit
   368                 result = self.redirect_handler(req, ex)
   362                 result = self.redirect_handler(req, ex)
   369             if req.cnx:
   363             if req.cnx: