Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #6679 -- In `decorator_from_middleware`, don't unpack arguments…

… when calling a middleware's

`process_view` method, thanks Gulopine.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7269 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d0032458a26bdd51729ce6ce372ec2c8094a96b6 1 parent 5794111
Gary Wilson Jr. authored March 17, 2008
2  django/utils/decorators.py
@@ -41,7 +41,7 @@ def _wrapped_view(request, *args, **kwargs):
41 41
                 if result is not None:
42 42
                     return result
43 43
             if hasattr(middleware, 'process_view'):
44  
-                result = middleware.process_view(request, view_func, *args, **kwargs)
  44
+                result = middleware.process_view(request, view_func, args, kwargs)
45 45
                 if result is not None:
46 46
                     return result
47 47
             try:
13  tests/regressiontests/utils/decorators.py
... ...
@@ -0,0 +1,13 @@
  1
+from django.test import TestCase
  2
+
  3
+class DecoratorFromMiddlewareTests(TestCase):
  4
+    """
  5
+    Tests for view decorators created using
  6
+    ``django.utils.decorators.decorator_from_middleware``.
  7
+    """
  8
+
  9
+    def test_process_view_middleware(self):
  10
+        """
  11
+        Test a middleware that implements process_view.
  12
+        """
  13
+        self.client.get('/utils/xview/')
1  tests/regressiontests/utils/tests.py
@@ -8,6 +8,7 @@
8 8
 
9 9
 import timesince
10 10
 import datastructures
  11
+from decorators import DecoratorFromMiddlewareTests
11 12
 
12 13
 # Extra tests
13 14
 __test__ = {
7  tests/regressiontests/utils/urls.py
... ...
@@ -0,0 +1,7 @@
  1
+from django.conf.urls.defaults import *
  2
+
  3
+import views
  4
+
  5
+urlpatterns = patterns('',
  6
+    (r'^xview/$', views.xview),
  7
+)
10  tests/regressiontests/utils/views.py
... ...
@@ -0,0 +1,10 @@
  1
+from django.http import HttpResponse
  2
+from django.utils.decorators import decorator_from_middleware
  3
+from django.middleware.doc import XViewMiddleware
  4
+
  5
+
  6
+xview_dec = decorator_from_middleware(XViewMiddleware)
  7
+
  8
+def xview(request):
  9
+    return HttpResponse()
  10
+xview = xview_dec(xview)
4  tests/urls.py
@@ -11,10 +11,12 @@
11 11
 
12 12
     # test urlconf for {% url %} template tag
13 13
     (r'^url_tag/', include('regressiontests.templates.urls')),
14  
-    
  14
+
15 15
     # django built-in views
16 16
     (r'^views/', include('regressiontests.views.urls')),
17 17
 
18 18
     # test urlconf for middleware tests
19 19
     (r'^middleware/', include('regressiontests.middleware.urls')),
  20
+
  21
+    (r'^utils/', include('regressiontests.utils.urls')),
20 22
 )

0 notes on commit d003245

Please sign in to comment.
Something went wrong with that request. Please try again.