Re: Patch for 404 customization

"Jonathan Ellis" <[email protected]>
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
On Tue, 16 May 2006 11:24:56 -0400, "Philip Semanchuk"
<[email protected]> said:
> Hi all,
> I have hacked Spyce to permit customization of 404 errors and I'd like 
> to hear other people's comments on my code. The 404 topic was discussed 
> on the list last fall. The short story as I understand it is that (a) 
> the comments in spyceconf.py (the part about "...errors include 
> spyce.spyceNotFound, spyce.spyceForbidden...") is incorrect and (b) 
> there's no way to override 404s. The last message on the topic was here 
> (although you might not be able to get there at the moment because 
> Sourceforge is having a bad hair day):
> http://sourceforge.net/mailarchive/message.php?msg_id=13225440
> 
> Conceptually, this code allows for customization of any error response 
> code, but I think the only one that Spyce returns at the moment is 404. 
> Since I don't understand Spyce internals, my goal was to change as 
> little code as possible. That also means less typing. =)
> 
> The first part of the change is to patch spyceWWW.py as per the diff at 
> the end of this message. Next, add a dict to spyceconf.py that looks 
> something like this:
> errorresponsecodehandlers = { 404 : "/Error404.spy" }
> Each entry in the dict consists of the response code you want to trap 
> and the file by which it should be processed. Last but not least, you 
> have to create /Error404.spy. Mine looks something like this:
> <html>
> <body>
> <p>Response code is [[=response._response.returncode]]</p>
> <p>URL stack is [[=request.stack()]]</p>
> </body>
> </html>

Hey Philip,

thanks for the patch.  But I think this is more complicated than it
needs to be.  All you should have to do call spyceFileHandler with the
(invalid) path instead of handling the 404 directly in spyceWWW, and it
should get routed through the normal exception handling stuff in
commonHandler.  Then the docs would be correct. :)

Does that make sense?

-Jonathan
-- 
C++ is history repeated as tragedy. Java is history repeated as farce.  --Scott McKay



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.