Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Using views for exceptions in Zope 2.12?

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


chris at simplistix

May 8, 2009, 1:01 AM

Post #1 of 7 (906 views)
Permalink
Using views for exceptions in Zope 2.12?

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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


hannosch at hannosch

May 8, 2009, 1:59 AM

Post #2 of 7 (856 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


chris at simplistix

May 9, 2009, 8:52 AM

Post #3 of 7 (851 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


sidnei.da.silva at gmail

May 9, 2009, 8:04 PM

Post #4 of 7 (852 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris [at] simplistix> 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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


l at lrowe

May 10, 2009, 3:51 AM

Post #5 of 7 (825 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

Sidnei da Silva wrote:
> On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris [at] simplistix> 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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


jim at zope

May 10, 2009, 4:19 AM

Post #6 of 7 (837 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

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


_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


chris at simplistix

May 16, 2009, 7:42 AM

Post #7 of 7 (735 views)
Permalink
Re: Using views for exceptions in Zope 2.12? [In reply to]

Laurence Rowe wrote:
> Sidnei da Silva wrote:
>> On Sat, May 9, 2009 at 12:52 PM, Chris Withers <chris [at] simplistix> 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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.