[Grok-dev] grok error page customization, DRY
Philipp von Weitershausen
philipp at weitershausen.de
Mon Aug 18 11:08:52 EDT 2008
Jasper Spaans wrote:
> Hi list,
>
> Today, I was working on a custom error page, and got bitten by the
> fact that it needs a grok.name('index.html'):
>
> from zope.publisher.interfaces import INotFound
> from zope.app.exception.systemerror import SystemErrorView
> ...
> class CobesNotFound(grok.View, SystemErrorView):
Why are you inheriting from SystemErrorView? AFAIK, doing that will only
gain you the ISystemErrorView interface which causes the publication to
log the exception as a "SiteError".
> grok.context(INotFound)
> grok.template('notfound')
> grok.name('index.html')
>
> def update(self):
> _set_no_cache_headers(self.response)
> self.response.setStatus(404)
>
>
> This feels like I'm repeating myself, so is there some way to fix this?
Apart from the 'index.html' bit which is annoying but not dramatic, what
is it that you'd like to fix?
Note that we Grok could actually set the default view for all Exceptions
to 'index' as well. That would make the 'index.html' pain go away. Of
course doing this would break everybody's custom exception views because
right now they'd be registered as 'index.html'.
More information about the Grok-dev
mailing list