[Zope] Exceptions in Python Script

Paul Winkler pw_lists@slinkp.com
Wed, 18 Dec 2002 14:23:25 -0800


On Wed, Dec 18, 2002 at 09:54:26PM +0000, Kevin Gill wrote:
> I want such logic as:
> 
> 
>         pt = container.x
>         return pt()
>     except AccessControl.unauthorized.Unauthorized:


You're missing the "try" keyword:

try: 
   do_something()
except SomeErrorClass:
   do_something_else()

> But access to the python exception functionality is not available. 

Yes it is.

> Furthermore, access to the sys variables for exceptions are also not 
> available.

The what variables?
 
> When I use page templates I have a variable called '_', and can do some nasty 
> work ....
> 
>     error = _['error']
>     if str(error.type) == "AccessControl.unauthorized.Unauthorized":
>         return container.acl_users.redirectToLogin(request)
> 
> However, there is no _ in the python script.

I'm very confused. Are you talking about the DTML namespace variable?
What do you do with a _ variable in Page Templates?
 
-- 

Paul Winkler
http://www.slinkp.com
"Welcome to Muppet Labs, where the future is made - today!"