mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #13093 -- Updated some decorators and the decorator_from_middleware function to allow callable classes to be decorated. Thanks to Brian Neal for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12762 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -11,3 +11,9 @@ class DecoratorFromMiddlewareTests(TestCase):
|
||||
Test a middleware that implements process_view.
|
||||
"""
|
||||
self.client.get('/utils/xview/')
|
||||
|
||||
def test_callable_process_view_middleware(self):
|
||||
"""
|
||||
Test a middleware that implements process_view, operating on a callable class.
|
||||
"""
|
||||
self.client.get('/utils/class_xview/')
|
||||
|
||||
@@ -4,4 +4,5 @@ import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^xview/$', views.xview),
|
||||
(r'^class_xview/$', views.class_xview),
|
||||
)
|
||||
|
||||
@@ -8,3 +8,10 @@ xview_dec = decorator_from_middleware(XViewMiddleware)
|
||||
def xview(request):
|
||||
return HttpResponse()
|
||||
xview = xview_dec(xview)
|
||||
|
||||
|
||||
class ClassXView(object):
|
||||
def __call__(self, request):
|
||||
return HttpResponse()
|
||||
|
||||
class_xview = xview_dec(ClassXView())
|
||||
|
||||
Reference in New Issue
Block a user