Commits

Remi Delon  committed 6231d1a

Deprecating simpleCookie (use "simple_cookie" instead)

  • Participants
  • Parent commits 3dc14e2

Comments (0)

Files changed (4)

File cherrypy/_cphttptools.py

         
         self.headers = httptools.HeaderMap()
         self.headerMap = self.headers # Backward compatibility
-        self.simpleCookie = Cookie.SimpleCookie()
+        self.simple_cookie = Cookie.SimpleCookie()
+        self.simpleCookie = self.simple_cookie # Backward compatibility
         
         if cherrypy.profiler:
             cherrypy.profiler.run(self._run)
             value = value.strip()
             # Warning: if there is more than one header entry for cookies (AFAIK,
             # only Konqueror does that), only the last one will remain in headers
-            # (but they will be correctly stored in request.simpleCookie).
+            # (but they will be correctly stored in request.simple_cookie).
             self.headers[name] = value
             
             # Handle cookies differently because on Konqueror, multiple
             # cookies come on different lines with the same key
             if name.title() == 'Cookie':
-                self.simpleCookie.load(value)
+                self.simple_cookie.load(value)
         
         # Save original values (in case they get modified by filters)
         # This feature is deprecated in 2.2 and will be removed in 2.3.
             "Set-Cookie": [],
             "Content-Length": None
         })
-        self.simpleCookie = Cookie.SimpleCookie()
+        self.simple_cookie = Cookie.SimpleCookie()
+        self.simpleCookie = self.simple_cookie # Backward compatibility
     
     def collapse_body(self):
         newbody = ''.join([chunk for chunk in self.body])
         header_list.sort()
         self.header_list = [item[1] for item in header_list]
         
-        cookie = self.simpleCookie.output()
+        cookie = self.simple_cookie.output()
         if cookie:
             lines = cookie.split("\n")
             for line in lines:

File cherrypy/filters/sessionfilter.py

             sess.session_storage.clean_up()
         
         # Check if request came with a session ID
-        if cookie_name in cherrypy.request.simpleCookie:
+        if cookie_name in cherrypy.request.simple_cookie:
             # It did: we mark the data as needing to be loaded
-            sess.session_id = cherrypy.request.simpleCookie[cookie_name].value
+            sess.session_id = cherrypy.request.simple_cookie[cookie_name].value
             
             # If using implicit locking, acquire lock
             if sess.session_locking == 'implicit':
             sess.session_data = {'_id': sess.session_id}
             sess.on_create_session(sess.session_data)
         # Set response cookie
-        cookie = cherrypy.response.simpleCookie
+        cookie = cherrypy.response.simple_cookie
         cookie[cookie_name] = sess.session_id
         cookie[cookie_name]['path'] = cookie_path
         cookie[cookie_name]['max-age'] = sess.session_timeout * 60

File cherrypy/test/test_core.py

 class Cookies(Test):
     
     def single(self, name):
-        cookie = cherrypy.request.simpleCookie[name]
-        cherrypy.response.simpleCookie[name] = cookie.value
+        cookie = cherrypy.request.simple_cookie[name]
+        cherrypy.response.simple_cookie[name] = cookie.value
     
     def multiple(self, names):
         for name in names:
-            cookie = cherrypy.request.simpleCookie[name]
-            cherrypy.response.simpleCookie[name] = cookie.value
+            cookie = cherrypy.request.simple_cookie[name]
+            cherrypy.response.simple_cookie[name] = cookie.value
 
 class MaxRequestSize(Test):
     

File docs/book/xml/apireference.xml

             example, "GET /path/page HTTP/1.1".</para>
         </section>
         <section>
-            <title>cherrypy.request.simpleCookie</title>
+            <title>cherrypy.request.simple_cookie</title>
             <para>This attribute is a SimpleCookie instance from the standard library's Cookie module
             which contains the incoming cookie values from the client.</para>
         </section>
             instead.</para>
         </section>
         <section>
-            <title>cherrypy.response.simpleCookie</title>
+            <title>cherrypy.response.simple_cookie</title>
             <para>This attribute is a SimpleCookie instance from the standard library's Cookie
             module. It contains the outgoing cookie values.</para>
         </section>
             response finalizing stage.</para>
         </section>
     </section>
-</section>
+</section>