wsgi/handler.py
changeset 9289 9bb7b5dc4214
parent 9287 e70c8c70e344
child 9402 2c48c091b6a2
equal deleted inserted replaced
9288:823cf14bcc37 9289:9bb7b5dc4214
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """WSGI request handler for cubicweb"""
    18 """WSGI request handler for cubicweb"""
    19 
       
    20 
       
    21 
    19 
    22 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    23 
    21 
    24 from itertools import chain, repeat, izip
    22 from itertools import chain, repeat, izip
    25 
    23 
    90 
    88 
    91     def __iter__(self):
    89     def __iter__(self):
    92         return iter(self.body)
    90         return iter(self.body)
    93 
    91 
    94 
    92 
    95 
       
    96 class CubicWebWSGIApplication(object):
    93 class CubicWebWSGIApplication(object):
    97     """This is the wsgi application which will be called by the
    94     """This is the wsgi application which will be called by the
    98     wsgi server with the WSGI ``environ`` and ``start_response``
    95     wsgi server with the WSGI ``environ`` and ``start_response``
    99     parameters.
    96     parameters.
   100     """
    97     """
   106         self.url_rewriter = self.appli.vreg['components'].select_or_none('urlrewriter')
   103         self.url_rewriter = self.appli.vreg['components'].select_or_none('urlrewriter')
   107 
   104 
   108     def _render(self, req):
   105     def _render(self, req):
   109         """this function performs the actual rendering
   106         """this function performs the actual rendering
   110         """
   107         """
   111         if self.base_url is None:
       
   112             self.base_url = self.config._base_url = req.base_url()
       
   113         try:
   108         try:
   114             path = req.path
   109             path = req.path
   115             result = self.appli.handle_request(req, path)
   110             result = self.appli.handle_request(req, path)
   116         except DirectResponse as ex:
   111         except DirectResponse as ex:
   117             return ex.response
   112             return ex.response