[Zope] manage_addPythonScript

Dieter Maurer dieter@handshake.de
Thu, 15 May 2003 21:09:20 +0200


Charles Zealey wrote at 2003-5-15 14:39 +0100:
 > I'm haing some problems calling manage_addPythonScript.  While the manual 
 > mentions it's existence I can find no examples of how to call it (a common 
 > complaint!).
 > 
 > However, when I get something that runs I get 
 > 
 > Error Type: TypeError
 > Error Value: 'in' or 'not in' needs sequence right argument
 > 
 > (which I have only ever seen where python versions are wrong.....)
 > 
 > Is this a permisssions problem, a bug, or simply user error?
 > 
 > I'd appreciate your wisdom.......

The primary wisdom is to look at the traceback :-)

It tells you that the problem is in line 2 of your Python Script "test".
 > ...
 > # Example code:
 > from Products.PythonScripts.PythonScript import PythonScript
 > ...
 >   File Script (Python), line 2, in test
 >   File /home/usr/local/src/Zope/lib/python/AccessControl/ZopeGuards.py, line 
 > 144, in guarded_import
 >   File /home/usr/local/src/Zope/lib/python/AccessControl/SecurityManager.py, 
 > line 83, in validate
 >   File 
 > /home/usr/local/src/Zope/lib/python/AccessControl/ZopeSecurityPolicy.py, line 
 > 157, in validate
 > TypeError: (see above)

I expect that your are not allowed to import the module "PythonScript".

I agree however that this error message gives you little chance to see this.

Please file a bug report to <http://collector.zope.org/Zope>.


The standard method to create a PythonScript (in an ObjectManager "om")
is:

	om.manage_addProduct['PythonScripts'].manage_addPythonScript(id)
	myPythonScript= getattr(om,id)

You can later use the PythonScript method "ZPythonScript_edit"
to set parameters and body of the script.


Dieter