[Grok-dev] Custom not found page
Wichert Akkerman
wichert at wiggy.net
Sat Nov 14 04:24:10 EST 2009
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)
That gives you a more common context and exposes the exception as
view.exception. I would expect a similar trick to work in a Zope 3
environment as well.
Wichert.
More information about the Grok-dev
mailing list