On Tue, 8 Apr 2003 soif@... wrote:
> I 'm looking for a way to do something like that :
> http://hotwired.lycos.com/webmonkey/02/26/index4a_page5.html?tw=programming
>
> i use mod_webkit. I really understand how to do this but
> i don't know how to call 404 handler instead of the mod_webkit
Currently, I set up my 404 handler by putting the following in the
`__init__.py` of my WebKit context:
def contextInitialize(application, context_path):
...
application.handleBadURL = new_bad_url_handler
...
def new_bad_url_handler(transaction):
response = transaction.response()
response.setHeader('Status', '301 Redirect')
response.setHeader('Location', '/public/de/tfound')
This may seem a little strange, but, after all, Python makes such
things possible. ;-) It's possible because the argument `application`
is an object, not a class, and thus I have to "inject" a bound method
(note the "missing" `self` in `new_bad_url_handler`).
See the topic "TransactionAnatomy" on the Webware Wiki for some notes
on the `handleBadURL` method.
Stefan
|