diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-06-20 03:48:31 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-06-20 03:48:31 +0000 |
| commit | 136752ca9a87be908f9ec1e398bbd56b0c75222c (patch) | |
| tree | f8ba00ebfda2cb7bd0c559ac3064407bcbc68330 /django | |
| parent | a09682fd6376159f81de9d6dc8c86ebd4e0b6513 (diff) | |
Added 'method' attribute to HttpRequest objects
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/handlers/modpython.py | 4 | ||||
| -rw-r--r-- | django/core/handlers/wsgi.py | 1 | ||||
| -rw-r--r-- | django/http/__init__.py | 5 |
3 files changed, 8 insertions, 2 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index ce7f6f1ad2..5a20ce9f67 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -98,6 +98,9 @@ class ModPythonRequest(http.HttpRequest): self._raw_post_data = self._req.read() return self._raw_post_data + def _get_method(self): + return self.META['REQUEST_METHOD'].upper() + GET = property(_get_get, _set_get) POST = property(_get_post, _set_post) COOKIES = property(_get_cookies, _set_cookies) @@ -105,6 +108,7 @@ class ModPythonRequest(http.HttpRequest): META = property(_get_meta) REQUEST = property(_get_request) raw_post_data = property(_get_raw_post_data) + method = property(_get_method) class ModPythonHandler(BaseHandler): def __call__(self, req): diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 01dbdf02f1..e9b9f9c1ff 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -55,6 +55,7 @@ class WSGIRequest(http.HttpRequest): self.environ = environ self.path = environ['PATH_INFO'] self.META = environ + self.method = environ['REQUEST_METHOD'].upper() def __repr__(self): from pprint import pformat diff --git a/django/http/__init__.py b/django/http/__init__.py index 178510c94c..efc1286f6d 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -12,11 +12,12 @@ except ImportError: class Http404(Exception): pass -class HttpRequest(object): # needs to be new-style class because subclasses define "property"s +class HttpRequest(object): "A basic HTTP request" def __init__(self): self.GET, self.POST, self.COOKIES, self.META, self.FILES = {}, {}, {}, {}, {} self.path = '' + self.method = None def __repr__(self): return '<HttpRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ @@ -282,7 +283,7 @@ class HttpResponseServerError(HttpResponse): self.status_code = 500 def get_host(request): - """Gets the HTTP host from the environment or request headers.""" + "Gets the HTTP host from the environment or request headers." host = request.META.get('HTTP_X_FORWARDED_HOST', '') if not host: host = request.META.get('HTTP_HOST', '') |
