[web] Avoid using an empty dict as default parameter of 'CubicWebRequestBase'.
authorDamien Garaud <damien.garaud@logilab.fr>
Tue, 04 Mar 2014 18:28:46 +0100
changeset 9549 a1f94c2d2a39
parent 9548 be001628edad
child 9550 0188e957ce84
[web] Avoid using an empty dict as default parameter of 'CubicWebRequestBase'. Also update the related docstring of the __init__ method.
web/request.py
--- a/web/request.py	Tue Jan 21 18:30:16 2014 +0100
+++ b/web/request.py	Tue Mar 04 18:28:46 2014 +0100
@@ -89,11 +89,12 @@
     """
     ajax_request = False # to be set to True by ajax controllers
 
-    def __init__(self, vreg, https=False, form=None, headers={}):
+    def __init__(self, vreg, https=False, form=None, headers=None):
         """
         :vreg: Vregistry,
         :https: boolean, s this a https request
         :form: Forms value
+        :headers: dict, request header
         """
         super(_CubicWebRequestBase, self).__init__(vreg)
         #: (Boolean) Is this an https request.
@@ -114,8 +115,9 @@
         self.html_headers = HTMLHead(self)
         #: received headers
         self._headers_in = Headers()
-        for k, v in headers.iteritems():
-            self._headers_in.addRawHeader(k, v)
+        if headers is not None:
+            for k, v in headers.iteritems():
+                self._headers_in.addRawHeader(k, v)
         #: form parameters
         self.setup_params(form)
         #: received body