=== added directory 'tests/regressiontests/requests'
=== added file 'tests/regressiontests/requests/__init__.py'
|
|
|
|
| | 1 | """ |
| | 2 | Tests for Django's various Request objects. |
| | 3 | """ |
=== added file 'tests/regressiontests/requests/models.py'
|
|
|
|
| | 1 | # Need a models module for the test runner. |
=== added file 'tests/regressiontests/requests/tests.py'
|
|
|
|
| | 1 | """ |
| | 2 | >>> from django.http import HttpRequest |
| | 3 | >>> print repr(HttpRequest()) |
| | 4 | <HttpRequest |
| | 5 | GET:{}, |
| | 6 | POST:{}, |
| | 7 | COOKIES:{}, |
| | 8 | META:{}> |
| | 9 | |
| | 10 | >>> from django.core.handlers.wsgi import WSGIRequest |
| | 11 | >>> print repr(WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'})) |
| | 12 | <WSGIRequest |
| | 13 | GET:<QueryDict: {}>, |
| | 14 | POST:<QueryDict: {}>, |
| | 15 | COOKIES:{}, |
| | 16 | META:{'REQUEST_METHOD': 'bogus', 'PATH_INFO': 'bogus'}> |
| | 17 | |
| | 18 | >>> from django.core.handlers.modpython import ModPythonRequest |
| | 19 | >>> class FakeModPythonRequest(ModPythonRequest): |
| | 20 | ... def __init__(self, *args, **kwargs): |
| | 21 | ... super(FakeModPythonRequest, self).__init__(*args, **kwargs) |
| | 22 | ... self._get = self._post = self._meta = self._cookies = {} |
| | 23 | >>> class Dummy: pass |
| | 24 | ... |
| | 25 | >>> req = Dummy() |
| | 26 | >>> req.uri = 'bogus' |
| | 27 | >>> print repr(FakeModPythonRequest(req)) |
| | 28 | <ModPythonRequest |
| | 29 | path:bogus, |
| | 30 | GET:{}, |
| | 31 | POST:{}, |
| | 32 | COOKIES:{}, |
| | 33 | META:{}> |
| | 34 | """ |
=== modified file 'django/core/handlers/modpython.py'
|
|
|
|
| 2 | 2 | from django.core import signals |
| 3 | 3 | from django.dispatch import dispatcher |
| 4 | 4 | from django.utils import datastructures |
| 5 | | from django.utils.encoding import force_unicode |
| | 5 | from django.utils.encoding import force_unicode, smart_str |
| 6 | 6 | from django import http |
| 7 | 7 | from pprint import pformat |
| 8 | 8 | import os |
| … |
… |
|
| 35 | 35 | meta = pformat(self.META) |
| 36 | 36 | except: |
| 37 | 37 | meta = '<could not parse>' |
| 38 | | return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ |
| 39 | | (self.path, get, post, cookies, meta) |
| | 38 | return smart_str(u'<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % |
| | 39 | (self.path, unicode(get), unicode(post), |
| | 40 | unicode(cookies), unicode(meta))) |
| 40 | 41 | |
| 41 | 42 | def get_full_path(self): |
| 42 | 43 | return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') |