[Zope] using exceptions in python scripts
Tim Hicks
tim@sitefusion.co.uk
Thu, 31 Jan 2002 11:18:44 -0000
> Dear Zope Users,
>
> Fairly new to Zope, but I am writing a Python Script. I would like to
> use exceptions in my processing flow, but the security restrictions
> won't allow it. What is the recommended approach here?
<snip sample>
Roy,
recently had this problem and found that I needed to use a (very minimal)
product to allow imports into python scripts. I think I already posted it
to this list asking people if they saw any problems. I got no response, so
I presume nobody saw anything terribly bad.
So, here it is again, only with a couple more comments...
----Begin customImports/__init__.py----
from Products.PythonScripts.Utility import allow_module, allow_class
from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
from Globals import InitializeClass
allow_module('exceptions') # Don't think you need this in fact
allow_module('traceback') # See below
ModuleSecurityInfo('sys').declarePublic('exc_info')
#Probably only need the line below instead of allowing the whole 'traceback'
module
#ModuleSecurityInfo('traceback').declarePublic('extract_tb')
----End __init__.py----
That's it. Put this file in a folder with whatever name you fancy (I chose
customImports) in your Products directory and restart zope.
hth
tim