[Zope] Exceptions and Python Scripts

Dieter Maurer dieter@handshake.de
Wed, 7 Feb 2001 21:54:50 +0100 (CET)


Chris Withers writes:
 > Hi,
 > 
 > I'd like to do a try...except in a Python Script.
 > 
 > Unfortunately, it doesn't look like I'm allowed to import the exceptions module:
 > 
 > Error Type: ImportError
 > Error Value: import of "Exceptions" is unauthorized
In Python, they are build in.
Aren't they in PythonScripts?
They should be (this is a wish).

 > To make matters worse, a lot of Zope's internals still throw string based
 > errors, so a very general except clause is the only way to catch them.
 > Unfortunately, the only way to analyise those exceptions is to use
 > sys.exec_info(), but using that in a python script always throws up an
 > authenticatino box.
You can selectively (unfortunatly only globally) allow import.
The list archive will tell you the details.

It is something like (in a product):

   import module; module.__allow_access_to_unprotected_objects=spec

   with "spec" set to "1" for unrestricted access to all module
   variables and "spec" set to a dictionary mapping to "1"
   for controlled access.



Dieter