Hello,
I was wondering why there is a break in this code?
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
The reason I ask is I was not able to use
https://github.com/omarish/django-cprofile-middleware unless I commented out the last two lines.
My objects look like the following:
self=<django.core.handlers.wsgi.WSGIHandler object at 0x7ff3c1320a90>
self._view_middleware=[<bound method DebugToolbarMiddleware.process_view of <debug_toolbar.middleware.DebugToolbarMiddleware object at 0x7ff3ab62d750>>, <bound method ProfilerMiddleware.process_view of <django_cprofile_middleware.middleware.ProfilerMiddleware object at 0x7ff3ab62dad0>>, <bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7ff3ab62db90>>]
With the 'break' included as-is, the 'for' loop was exiting after the first iteration, as there is a 'response'.
response=<django.template.response.TemplateResponse object at 0x7f8d978e1d50>
and the web page displays the following error:
------------------------------
AttributeError at /data/taxonomy/1/
'ProfilerMiddleware' object has no attribute 'profiler'
Request Method: | GET |
---|
Request URL: | http://152.16.15.249:8091/data/taxonomy/1/?prof |
---|
Django Version: | 1.6.1 |
---|
Exception Type: | AttributeError |
---|
Exception Value: | 'ProfilerMiddleware' object has no attribute 'profiler' |
---|
Exception Location: | /home/jeremiah/.virtualenvs/auto_p3_d16/lib/python3.3/site-packages/django_cprofile_middleware/middleware.py in process_response, line 49 |
---|
|
------------------------------------
Without the last two lines, I am able to use the profiler without errors.
Is the 'break' needed?
Thanks,
Jeremiah