Changeset 5342
- Timestamp:
- 05/25/07 04:48:02 (1 year ago)
- Files:
-
- django/branches/unicode/django/core/handlers/modpython.py (modified) (2 diffs)
- django/branches/unicode/django/core/handlers/wsgi.py (modified) (2 diffs)
- django/branches/unicode/django/http/__init__.py (modified) (2 diffs)
- django/branches/unicode/docs/unicode.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/core/handlers/modpython.py
r5126 r5342 50 50 self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data) 51 51 else: 52 self._post, self._files = http.QueryDict(self.raw_post_data ), datastructures.MultiValueDict()52 self._post, self._files = http.QueryDict(self.raw_post_data, encoding=self._encoding), datastructures.MultiValueDict() 53 53 54 54 def _get_request(self): … … 59 59 def _get_get(self): 60 60 if not hasattr(self, '_get'): 61 self._get = http.QueryDict(self._req.args )61 self._get = http.QueryDict(self._req.args, encoding=self._encoding) 62 62 return self._get 63 63 django/branches/unicode/django/core/handlers/wsgi.py
r5126 r5342 114 114 self._post, self._files = http.parse_file_upload(header_dict, self.raw_post_data) 115 115 else: 116 self._post, self._files = http.QueryDict(self.raw_post_data ), datastructures.MultiValueDict()116 self._post, self._files = http.QueryDict(self.raw_post_data, encoding=self._encoding), datastructures.MultiValueDict() 117 117 else: 118 self._post, self._files = http.QueryDict('' ), datastructures.MultiValueDict()118 self._post, self._files = http.QueryDict('', encoding=self._encoding), datastructures.MultiValueDict() 119 119 120 120 def _get_request(self): … … 126 126 if not hasattr(self, '_get'): 127 127 # The WSGI spec says 'QUERY_STRING' may be absent. 128 self._get = http.QueryDict(self.environ.get('QUERY_STRING', '') )128 self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''), encoding=self._encoding) 129 129 return self._get 130 130 django/branches/unicode/django/http/__init__.py
r5310 r5342 19 19 class HttpRequest(object): 20 20 "A basic HTTP request" 21 22 # The encoding used in GET/POST dicts. None means use default setting. 23 _encoding = None 24 21 25 def __init__(self): 22 26 self.GET, self.POST, self.COOKIES, self.META, self.FILES = {}, {}, {}, {}, {} … … 43 47 def is_secure(self): 44 48 return os.environ.get("HTTPS") == "on" 49 50 def _set_encoding(self, val): 51 """ 52 Sets the encoding used for GET/POST accesses. 53 """ 54 self._encoding = val 55 if hasattr(self, '_get'): 56 self.GET.encoding = val 57 if hasattr(self, '_post'): 58 self.POST.encoding = val 59 60 def _get_encoding(self): 61 return self._encoding 62 63 encoding = property(_get_encoding, _set_encoding) 45 64 46 65 def parse_file_upload(header_dict, post_data): django/branches/unicode/docs/unicode.txt
r5340 r5342 338 338 for form data. If you need to change this for a particular form, you can set 339 339 the ``encoding`` attribute on the ``GET`` and ``POST`` data structures. For 340 example:: 340 convenience, changing the ``encoding`` property on an ``HttpRequest`` instance 341 does this for you. For example:: 341 342 342 343 def some_view(request): 343 344 # We know that the data must be encoded as KOI8-R (for some reason). 344 request.GET.encoding = 'koi8-r' 345 request.POST.encoding = 'koi8-r' 345 request.encoding = 'koi8-r' 346 346 ... 347 348 You can even change the encoding after having accessed ``request.GET`` or 349 ``request.POST`` and all subsequent accesses will use the new encoding. 347 350 348 351 It will typically be very rare that you would need to worry about changing the
