1. cherrypy
  2. CherryPy

Commits

Christian Wyglendowski  committed d306416

When running under _cphttpserver, request.wsgi_environ is now set to an empty dictionary. It will still evaluate as boolean False, but will allow for the following code:

val = cherrypy.request.wsgi_environ.get('SOME_VAR', 'some default')

Rather than:

if cherrypy.request.wsgi_environ:
val = cherrypy.request.wsgi_environ['SOME_VAR']
else:
val = 'some default'

  • Participants
  • Parent commits 5809c83
  • Branches default

Comments (0)

Files changed (2)

File cherrypy/_cphttpserver.py

View file
  • Ignore whitespace
                                               self.address_string(), "http")
             request.multithread = cherrypy.config.get("server.thread_pool") > 1
             request.multiprocess = False
-            request.wsgi_environ = False
+            request.wsgi_environ = {}
             response = request.run(self.raw_requestline, self._headerlist(),
                                    self.rfile)
             s, h, b = response.status, response.header_list, response.body

File docs/book/xml/apireference.xml

View file
  • Ignore whitespace
         </section>
         <section>
             <title>cherrypy.request.wsgi_environ</title>
-            <para>This attribute is a dictionary containing the WSGI environment for the request.  In non-WSGI settings, it is set to False.</para>
+            <para>This attribute is a dictionary containing the WSGI environment for the request.  In non-WSGI settings (i.e., running under _cphttpserver), it is an empty dictionary.</para>
         </section>
         <section>
             <title>cherrypy.request.queryString</title>