You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: 'ProfileSummaryModule' object has no attribute 'start' #28
The weird thing is that if I remove 'devserver.modules.profile.ProfileSummaryModule' from DEVSERVER_MODULES, reload the page and then re-add it and reload the page, it suddenly does work.
I think the broader issue is that the profile module doesn't handle the case where a different middleware object returns a valid HttpRequest. When this happens the middleware objects later in the request chain (which includes DevServerMiddleware, which sits at the end) don't get their process_request() method called. Which means no modules will get their process_init() method called.
But all the middleware objects' process_response() methods do get called, so DevServerMiddleware calls all modules' process_response(), and that's where the profile module breaks.
The profile module isn't guarding for this case. So one fix would be to make all modules more defensive about having their process_response() called without process_init().
Or, I think someone has suggested having DevServerMiddleware insert itself in the front of the middleware list, instead of at the end. (This may have other consequences.)
Or maybe DevServerMiddleware can check in process_response() to see it ever saw the request associated with the response, and if it did not, it protects its modules and doesn't call them in this case.
I'm not sure which approach makes the most sense. If it's ok to lose DevServer functionality for the cases where middleware responses are triggered, I guess I'd lean towards the last option. But if you want to be able to profile the middleware responses, prepending DevServerMiddleware may be the best option.
I like the idea of inserting ahead of the middleware list to be able to profile other middleware but that would be a much more invasive change. It seems like long-term it would be better to move state to either the request object or the cache and refactor everything to do a get/getattr with graceful failure handling.
Activity
ebaumgartner commentedon Apr 26, 2011
I think the broader issue is that the profile module doesn't handle the case where a different middleware object returns a valid HttpRequest. When this happens the middleware objects later in the request chain (which includes DevServerMiddleware, which sits at the end) don't get their process_request() method called. Which means no modules will get their process_init() method called.
But all the middleware objects' process_response() methods do get called, so DevServerMiddleware calls all modules' process_response(), and that's where the profile module breaks.
The profile module isn't guarding for this case. So one fix would be to make all modules more defensive about having their process_response() called without process_init().
Or, I think someone has suggested having DevServerMiddleware insert itself in the front of the middleware list, instead of at the end. (This may have other consequences.)
Or maybe DevServerMiddleware can check in process_response() to see it ever saw the request associated with the response, and if it did not, it protects its modules and doesn't call them in this case.
I'm not sure which approach makes the most sense. If it's ok to lose DevServer functionality for the cases where middleware responses are triggered, I guess I'd lean towards the last option. But if you want to be able to profile the middleware responses, prepending DevServerMiddleware may be the best option.
dlo commentedon Jul 22, 2011
Running into this too. Makes debugging a total nightmare.
Avoid failing when another middleware returns HttpResponse (closes dc…
acdha commentedon Aug 9, 2011
I got tired of this failing all the time on my django-localeurl-using site: acdha/django-devserver@0e2d1c0
I like the idea of inserting ahead of the middleware list to be able to profile other middleware but that would be a much more invasive change. It seems like long-term it would be better to move state to either the request object or the cache and refactor everything to do a get/getattr with graceful failure handling.
Merge pull request #44 from acdha/master
TylerBrock commentedon Aug 28, 2011
Bump! It would be great if this got fixed.