[Zope] how to use allow_module() and allow_class() ?

Dieter Maurer dieter@handshake.de
Fri, 29 Mar 2002 12:57:45 +0100


Doyon, Jean-Francois writes:
 > I am tryting to enable the use of a module in my Python scripts, but am
 > having trouble.
 > 
 > I have done as suggested in the PythonScripts/README.txt and created myself
 > a product with an __init__.py that has:
 > 
 > # Global module assertions for Python scripts
 > from Products.PythonScripts.Utility import allow_module, allow_class
 > 
 > allow_module('urllib')
 > allow_module('Projection')
 > 
 > BUT when I try to run a simple script such as:
 > 
 > 	from Projection import Projection, DEGREES
 > 
 > 	o =
 > Projection(['proj=lcc','lat_0=49n','lon_0=95w','lat_1=49n','lat_2=77n','ellp
 > s=GRS80'],DEGREES)
 > 	point = o.Forward(latlong[0],latlong[1])
 > 
 > 	return point
 > 
 > I get an unauthorized access error! ...
I expect, you get the "Unauthorized" from "o.Forward":

  The "allow_module" only provide for permission to import the module
  and use its content.
  In order to allow for attribute access to instances of classes
  defined in such modules, these classes need additional security
  assertions.

  Please read the Zope developper guide (--> zope.org) for details.



Dieter