aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2012-09-28 11:53:51 +0100
committerTom Christie2012-09-28 11:53:51 +0100
commit84f775803994ccd82671dd4a6f9b4d87aa36dc31 (patch)
treea28f8213f0ebce048b163d79d5c3e182b3f20171
parentaeeb68f68a8f5a3deb9f1ad06f11dbbd9a8f1ff6 (diff)
downloaddjango-rest-framework-84f775803994ccd82671dd4a6f9b4d87aa36dc31.tar.bz2
Remove support for doctests
-rw-r--r--rest_framework/renderers.py7
-rw-r--r--rest_framework/request.py16
-rw-r--r--rest_framework/tests/__init__.py2
3 files changed, 18 insertions, 7 deletions
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py
index 35a2a733..8f2a3570 100644
--- a/rest_framework/renderers.py
+++ b/rest_framework/renderers.py
@@ -5,13 +5,13 @@ Django REST framework also provides HTML and PlainText renderers that help self-
by serializing the output along with documentation regarding the View, output status and headers,
and providing forms and links depending on the allowed methods, renderers and parsers on the View.
"""
-import copy
import string
from django import forms
from django.template import RequestContext, loader
from django.utils import simplejson as json
from rest_framework.compat import yaml
from rest_framework.settings import api_settings
+from rest_framework.request import clone_request
from rest_framework.utils import dict2xml
from rest_framework.utils import encoders
from rest_framework.utils.breadcrumbs import get_breadcrumbs
@@ -227,12 +227,9 @@ class DocumentingHTMLRenderer(BaseRenderer):
if not api_settings.FORM_METHOD_OVERRIDE:
return # Cannot use form overloading
- temp = request._method
- request._method = method.upper()
+ request = clone_request(request, method)
if not view.has_permission(request):
- request._method = temp
return # Don't have permission
- request._method = temp
if method == 'DELETE' or method == 'OPTIONS':
return True # Don't actually need to return a form
diff --git a/rest_framework/request.py b/rest_framework/request.py
index 2034ccc6..e254cf8e 100644
--- a/rest_framework/request.py
+++ b/rest_framework/request.py
@@ -28,6 +28,22 @@ def _hasattr(obj, name):
return not getattr(obj, name) is Empty
+def clone_request(request, method):
+ """
+ Internal helper method to clone a request, replacing with a different
+ HTTP method. Used for checking permissions against other methods.
+ """
+ ret = Request(request._request,
+ request.parser_classes,
+ request.authentication_classes)
+ ret._data = request._data
+ ret._files = request._files
+ ret._content_type = request._content_type
+ ret._stream = request._stream
+ ret._method = method
+ return ret
+
+
class Request(object):
"""
Wrapper allowing to enhance a standard `HttpRequest` instance.
diff --git a/rest_framework/tests/__init__.py b/rest_framework/tests/__init__.py
index ba3a27c0..85ee18b6 100644
--- a/rest_framework/tests/__init__.py
+++ b/rest_framework/tests/__init__.py
@@ -7,6 +7,4 @@ modules = [filename.rsplit('.', 1)[0]
__test__ = dict()
for module in modules:
- exec("from rest_framework.tests.%s import __doc__ as module_doc" % module)
exec("from rest_framework.tests.%s import *" % module)
- __test__[module] = module_doc or ""