[Grok-dev] grok error page customization, DRY

Jasper Spaans jasper at vs19.net
Mon May 18 13:51:38 EDT 2009


Hi grokkers,

Digging up an old mail...

Op 18 aug 2008, om 17:08 heeft Philipp von Weitershausen het volgende  
geschreven:
> Jasper Spaans wrote:
>> 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):
>>     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?


... as I tried adding a proper exception page to a toy project of mine  
last weekend [1], and did not get it working until I found this thread  
and put in a grok.name('index.html').

Would a grok.ExceptionView class which has a default grok.name of  
index.html be a good idea? And is there a sane way to implement this?

Groet,
Jasper
-- 
Jasper Spaans                                          http://jasper.es/
              This line was last modified 0 seconds ago.

[1] https://secure.jasper.es/svn/tempthing/trunk/ for the code, http://jasper.es/temp 
  for a demo


More information about the Grok-dev mailing list