Ticket #1691 (closed defect: fixed)
Traceback on 404 status code for quickstart project
| Reported by: | khorn | Owned by: | anonymous |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | TurboGears | Version: | trunk |
| Severity: | major | Keywords: | |
| Cc: |
Description
as of: TG [3946], Pylons [1293:28eed5438061]
Using a new quickstarted project, when requesting a page that does not exist, the following traceback occurs:
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 3080)
Traceback (most recent call last):
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\httpserver.py", line 1046, in process_request_in_thread
self.finish_request(request, client_address)
File "C:\Python25\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python25\lib\SocketServer.py", line 522, in __init__
self.handle()
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\httpserver.py", line 425, in handle
BaseHTTPRequestHandler.handle(self)
File "C:\Python25\lib\BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\httpserver.py", line 420, in handle_one_request
self.wsgi_execute()
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\cascade.py", line 119, in __call__
return self.apps[-1](environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\registry.py",line 334, in __call__
app_iter = self.application(environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\recursive.py", line 84, in __call__
return middleware(environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\recursive.py", line 47, in __call__
return self.app(environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\errordocument.py", line 84, in __call__
return self.app(environ, keep_status_start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\recursive.py", line 80, in __call__
return self.application(environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\errordocument.py", line 185, in __call__
app_iter = self.application(environ, change_response)
File "c:\python25\lib\site-packages\weberror-0.8dev_20071111-py2.5.egg\weberror\evalexception\middleware.py", line 213, in __call__
return self.respond(environ, start_response)
File "c:\python25\lib\site-packages\weberror-0.8dev_20071111-py2.5.egg\weberror\evalexception\middleware.py", line 324, in respond
return self.application(environ, start_response)
File "c:\python25\lib\site-packages\toscawidgets-0.2rc3dev_r3795-py2.5.egg\toscawidgets\middleware.py", line 40, in __call__
return self.wsgi_app(environ, start_response)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\registry.py",line 334, in __call__
app_iter = self.application(environ, start_response)
File "c:\python25\lib\site-packages\toscawidgets-0.2rc3dev_r3795-py2.5.egg\toscawidgets\middleware.py", line 55, in wsgi_app
app_iter = self.application(environ, start_response)
File "c:\python25\lib\site-packages\Beaker-0.9-py2.5.egg\beaker\middleware.py", line 73, in __call__
return self.app(environ, start_response)
File "c:\python25\lib\site-packages\Beaker-0.9-py2.5.egg\beaker\middleware.py", line 145, in __call__
response = self.wrap_app(environ, session_start_response)
File "c:\documents and settings\ittemp2\desktop\mine_ph\pystuff\tg2\tg\__init__.py", line 79, in __call__
return self.root(environ, start_response)
File "C:\Documents and Settings\ittemp2\Desktop\mine_ph\pystuff\authtest\authtest\lib\base.py", line 39, in __call__
return TurboGearsController.__call__(self, environ, start_response)
File "c:\documents and settings\ittemp2\desktop\mine_ph\pystuff\pylons\pylons\controllers\core.py", line 218, in __call__
return response(environ, self.start_response)
File "c:\python25\lib\site-packages\webob-0.8.5-py2.5.egg\webob\exc.py", line228, in __call__
return self.generate_response(environ, start_response)
File "c:\python25\lib\site-packages\webob-0.8.5-py2.5.egg\webob\exc.py", line220, in generate_response
start_response(self.status, headerlist)
File "c:\python25\lib\site-packages\Beaker-0.9-py2.5.egg\beaker\middleware.py", line 143, in session_start_response
return start_response(status, headers, exc_info)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\errordocument.py", line 183, in change_response
return start_response(status, headers, exc_info)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\errordocument.py", line 75, in keep_status_start_response
replace_header(self.headers, header, value)
File "c:\python25\lib\site-packages\Paste-1.5.1-py2.5.egg\paste\response.py", line 155, in replace_header
assert not result, "two values for the header '%s' found" % name
AssertionError: two values for the header 'content-type' found
----------------------------------------
It seems that something changed during the sprint which is now preventing HTTP exception handling from working properly. I suspect the new WebOb? stuff is causing problems with ErroDocuments? middleware, but I can't prove it yet.
Change History
comment:2 Changed 4 years ago by percious
I wanted to add that I ran into the same problem in Python 2.5 on mac OS X.
comment:3 Changed 4 years ago by khorn
This also appears to happen when raising other HTTPExceptions, such as HTTPUnauthorized (401), etc.
comment:5 Changed 4 years ago by khorn
- Summary changed from Traceback on 404 status code to Traceback on 404 status code for quickstart project
I've verified that this problem DOES NOT occur when the ErrorDocument? middleware is disabled.
I think something with the new webob functionality is driving it nuts.
comment:6 Changed 4 years ago by khorn
Just for completeness, I'm seeing this on Win32 with Python 2.4 and 2.5.
comment:7 Changed 4 years ago by khorn
Pylons 0.9.7 seems to be moving to using WebError? instead of ErrorDocuments?, which will probably affect this ticket.
see the Error Handling section here: http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779
comment:8 Changed 4 years ago by mramm
I had a few min to look at this, and a simple update to midleware.py_tmpl should fix this. We just need to use StatusCodeRedirect? rather than ErrorDocument? as seen in this snippet from the current pylons template.
if asbool(full_stack):
# Handle Python exceptions
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
# Display error documents for 401, 403, 404 status codes (and
# 500 when debug is disabled)
if asbool(config['debug']):
app = StatusCodeRedirect(app)
else:
app = StatusCodeRedirect(app, [401, 403, 404, 500])
comment:9 Changed 4 years ago by khorn
I mentioned this on the mailing list a while back, but we were waiting on the 2.4 compatibility fixes to investigate this further.
comment:10 Changed 4 years ago by mramm
Submited a fix for this in trunk. Kevin, can you test this and make sure we're on the same page. Thanks!
comment:12 Changed 4 years ago by khorn
- Status changed from closed to reopened
- Resolution fixed deleted
shouldn't the ErrorDocuments? call also be removed?
I was under the impression that StatusCodeRedirect? did the same thing...
Also, StatusCodeRedirect? needs to be imported at the top of middleware.py_tmpl. a la:
from pylons.middleware import StatusCodeRedirect
as it is right now I get an import error when starting the quickstarted project
comment:13 Changed 4 years ago by khorn
- Status changed from reopened to closed
- Resolution set to fixed
fixed by Mark Ramm in [4113]
comment:14 Changed 3 years ago by anonymous
- Milestone 2.0-preview-1 deleted
Milestone 2.0-preview-1 deleted
OK, here's what the headers look like in the replace_headers function:
Now, where do they get set?