Hallo,
Hancock, David (DHANCOCK) hat gesagt: // Hancock, David (DHANCOCK) wrote:
> I won't profess to understanding exactly how this works, but one of our
> developers did exactly what you're trying to do. We wanted to save and email
> the full HTML "red-bar" traceback for oncall engineers, but we only wanted
> users to see a short message with an identifying number so we could
> correlate it on the system when they called in.
...
> The errorPageFilename uses a number returned by createRandomCode as part of
> the filename. The date from createTimeStamp is also used for the filename,
> so an error in servlet SomeFunc makes the file:
>
> Error-SomeFunc.py-01-Nov-03_15:09Z--11081.html
>
> It uses getPublicHTML to construct the contents of that file.
>
> The getPrivateHTML method is probably the one you're most interested in. It
> constructs a much smaller, kinder, gentler page for the user to see (with
> words like "We've encountered an error processing your request. If you need
> immediate assistance call 1-800-BITEME. Please reference code: 12345 when
> you call. We're sorry for the inconvenience."
Late answer here, but I finally got around to figure all this out. As
was recommended by you and others, I first looked into customizing
"privateErrorPage" but somehow it felt wrong, that I and Webware were
sending out something called "private" to the public. Then after a
bit more digging I found out, that this depends on the setting in
Application.Config:
If 'ShowDebugInfoOnErrors' is True, then the html generated by
privateErrorPage is sent to the user. If it is False, then the
"publicErrorPage" is sent. So I finally customized the public part and
kept my private parts for myself, so to say. Basically now my custom
exceptions look like this:
### __init__.py
from WebKit.ExceptionHandler import ExceptionHandler as _ExceptionHandler
class ExceptionHandler(_ExceptionHandler):
def publicErrorPage(self):
html = open("errorPage.html").read()
return html
def contextInitialize(app, ctxPath):
app._exceptionHandlerClass = ExceptionHandler
### end __init__
And this is in Application.Config:
...
'ShowDebugInfoOnErrors': 0,
...
'SaveErrorMessages': 1,
'EmailErrors': 1,
...
Thanks again for your pointers.
ciao
--
Frank Barknecht _ ______footils.org__
|