One thing I always disliked about Webware is the static 404 error page. First, the name '404Text.txt' is hard coded and misleading because it is a complete HTML page (maybe it has only been the body part in older versions, as it is still wrongly documented), so it should better be called something like '404page.html'.
Second, you usually define a custom layout and CSS in your base servlet class. If you don't want your 404 page to look completely different, you are forced to insert (duplicate) the layout manually in the 404Text.txt file. Therefore I'd like to be able to forward to an arbitrary servlet in case of a 404 error, or generally, any http error. This servlet could then simply use the same base class as the other servlets, and everything will look neatly. While you can install a customized error handler for exceptions that occurred in the servlets using the Application._exceptionHandlerClass, it does not seem to be possible to invoke a custom servlet on an HTTPException. (Or am I overlooking something obvious?) So I have just implemented such a feature, considering that I really would like to have that before Webware 1.0. I introduced a new Application.config setting "HTTPErrorPage". (If you have a better name, let me know. I do not want to call it "ErrorPage" because there are already many "Error" settings which all refer to servlet exceptions, not HTTPExceptions.) For example: HTTPErrorPage = { 'NotFound': '/Error404' 'SessionExpired': '/Expired', 'default': '/Error' } Webware will then forward to the URL '/Error404' if an HTTPNotFound exception is raised. Integer error codes are also allowed as keys (e.g. 401: '/Expired'), but the names of the exceptions are more readable and allow for finer granularity. E.g. 401 is also used for a more general "authentication required" error. In the case that you only have one page to be used as the default, I will allow the shorter notation: HTTPErrorPage = '/Error' If HTTPErrorPage is set to None, or you hit an HTTPException that is not in HTTPErrorPage and there is no default key, then Webware will behave exactly as before. The error servlet could look like that: ------------- Error404.py ---------------- from MyPage import MyPage class Error404(MyPage ): def title(self): return "This page does not exist!" def writeContent(self): self.write(""" <h4>You were not here:</h4> <h3>%s</h3> <h5>Let's never mention it again.</h5> """ % self.htmlEncode(self.request().uri())) -------------------------------------------- I have this already working. The error page will of course come with its associated status code in the http header, automatically. Let me know whether you think this all makes sense before I will check it in ;-) -- Chris ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Webware-devel mailing list Webware-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-devel