Hi All, Given that the source of bug #372632 appears to be code related to allowing views on exceptions in Zope 2, I thought I'd try use this method. I tried this, without much joy: <browser:defaultView for="exceptions.Exception" name="error" /> <browser:page for="exceptions.Exception" template="html/error.html" name="error" permission="zope2.Public" /> So, how should I be wiring in views for exceptions? Also, is there a base view class for exceptions anywhere that provides the following or their equivalents? kwargs = {'error_type': error_name, 'error_value': error_value, 'error_tb': error_tb, 'error_traceback': error_tb, 'error_message': error_message, 'error_log_url': error_log_url} Finally, when a view is used to render and exception, is the userthe current logged in user (as is the case with standard_error_message) or Anonymous (as has annoyingly been the case with Unauthorized exceptions in the past) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
Given that the source of bug #372632 appears to be code related to allowing views on exceptions in Zope 2, I thought I'd try use this method.
Try following the description given in the changelog at http://svn.zope.org/Zope/branches/2.11/doc/CHANGES.txt?view=markup under "Zope 3-based exception views". Hanno
Hanno Schlichting wrote:
Try following the description given in the changelog at http://svn.zope.org/Zope/branches/2.11/doc/CHANGES.txt?view=markup under "Zope 3-based exception views".
Hmm, so I would I register different views for a KeyError versus an AttributeError? cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris@simplistix.co.uk> wrote:
Hmm, so I would I register different views for a KeyError versus an AttributeError?
I believe you need to make KeyError implement an interface to be able to register a view for it. What use would be a view for KeyError anyway. *wink* -- Sidnei da Silva Canonical Ltd. Landscape · Changing the way you manage your systems http://landscape.canonical.com
Sidnei da Silva wrote:
On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris@simplistix.co.uk> wrote:
Hmm, so I would I register different views for a KeyError versus an AttributeError?
I believe you need to make KeyError implement an interface to be able to register a view for it. What use would be a view for KeyError anyway. *wink*
It's perfectly possible to register a view for a class instead of an interface. (Not that I am familiar with the new views for errors stuff). Laurence
Laurence Rowe wrote:
Sidnei da Silva wrote:
On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris@simplistix.co.uk> wrote:
Hmm, so I would I register different views for a KeyError versus an AttributeError? I believe you need to make KeyError implement an interface to be able to register a view for it. What use would be a view for KeyError anyway. *wink*
It's perfectly possible to register a view for a class instead of an interface.
That's exactly what I did, but my view wasn't used. Why is that? What magic is making view lookup for exceptions behave differently from normal view lookups? Chris
On May 9, 2009, at 11:52 AM, Chris Withers wrote:
Hanno Schlichting wrote:
Try following the description given in the changelog at http://svn.zope.org/Zope/branches/2.11/doc/CHANGES.txt?view=markup under "Zope 3-based exception views".
Hmm, so I would I register different views for a KeyError versus an AttributeError?
Not unless you actually need different views for them, which you probably don't. In my experience, you only need a few, as described in change notes. One additional one that isn't mentioned in the change notes but that I use a lot is UserError (zope.exceptions.UserError). This is an exception to raise when you want to display an end-user error message. Most exceptions are really application errors and should be handled by a view for Exception that displays a system error message. Jim -- Jim Fulton Zope Corporation
participants (5)
-
Chris Withers -
Hanno Schlichting -
Jim Fulton -
Laurence Rowe -
Sidnei da Silva