[Zope-dev] urgent: string exceptions

Jeffrey P Shell jeffrey@cuemedia.com
Fri, 11 Apr 2003 17:58:55 -0600


"Bad Request" is a special scenario that harkens back to Bobo 
(ZPublisher).  One of the elements of Bobo was that you could raise 
HTTP exceptions, and it would be turned into a proper (or as proper as 
possible) HTTP Response Code, like 302 or 404 or whatever.

This is some of the oldest code in Zope, and no one's really dealt with 
it (at least, not for Zope 2), because it's a decent effort to chase 
down all of the uses of it and patch things all the way down to the 
core to make use of it.  This is made even more prescient by the fact 
that this is core core core ZPublisher behavior and is not even really 
Zope specific, so it's questionable where to put the class based 
exceptions and where to declare their security options so that they can 
get used in scripts.

I'm not saying that it shouldn't be done, but that one has to 
understand the meaning behind it as well as the depth of the problem.  
Because of its potential impact, a well-thought proposal would have to 
be written up by someone who knew ZPublisher and Zope well enough to 
suggest a solution and document the potential impacts/risks involved 
with the change.

On Friday, April 11, 2003, at 02:26  AM, Christian Theune wrote:

> Hi.
>
> I'm stuck with trying to catch a string exception from the zope core
> within a python script of cmf.
>
> When using invokeFactory one can expect it to raise a "Bad Request"
> (string) exception e.g. when you want to create an object with a
> duplicate id.
>
> Within a python script I tried:
>
> try:
>     ... invokeFactory ...
> except "Bad Request", v:
>     ...
>
> but that doesn't catch the exception. Using an anonymous except: clause
> is not an acceptable way because a) they are evil b) i can't get to the
> exception value anymore.
>
> I need to solve a problem related to that soon. I now have some things 
> I
> can imagine to do:
>
> a) Remove "Bad Request" beeing a String exception and make it a class
> exception
>
> b) Get a hint on how to actually catch the string exception within a
> python script and get to the exception value
>
> c) (Not good but if it works) Catch it anonymously *and* get to the
> exception value.
>
> Thanks for listening,
> Christian
>
> -- 
> Christian Theune, gocept gmbh & co. kg
> http://www.gocept.com - ct@gocept.com
> fon: 03496 3099112 fax: 03496 3099118 mobile: 0179 7808366
>
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> 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 )