[Grok-dev] Custom not found page

Leonardo Rochael Almeida leorochael at gmail.com
Mon Nov 16 05:32:05 EST 2009


On Sat, Nov 14, 2009 at 10:24, Wichert Akkerman <wichert at wiggy.net> wrote:
> On 11/14/09 00:03 , Kevin Teague wrote:
>> Well, since you just asked for a "hint" and I don't have the full
>> answer :P
>>
>> You've got:
>>
>> metal:use-macro="context/@@mblosum/macros/standard"
>>
>> But in a INotFound view, the context isn't your Application object,
>> but a NotFound object.
>
> I've always found that to be somewhat confusing behaviour. In a Zope 2
> context I use an error view like this:
>
> class ErrorView(grok.View):
>     grok.context(Exception)
>     grok.name("index.html")
>     grok.template("error")
>
>     def update(self):
>         self.exception=aq_inner(self.context)
>         self.context=aq_parent(self)
>         log.exception("Error at %r", self.context)
>
>
> [...]

Perhaps we should generalize a trick like this in Grok itself. Say, in
a class like grok.ErrorView where grok.name() would already be set,
and grok.context() would be checked to be an actual Exception
subclass.

Cheers, Leo


More information about the Grok-dev mailing list