[Zope] manage_addPythonScript

Charles Zealey charles@itsolve.co.uk
Thu, 15 May 2003 14:39:27 +0100


I'm haing some problems calling manage_addPythonScript.  While the manual=
=20
mentions it's existence I can find no examples of how to call it (a commo=
n=20
complaint!).

However, when I get something that runs I get=20

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.......


Charles




My code: =20
# Example code:
from Products.PythonScripts.PythonScript import PythonScript
# Import a standard function, and get the HTML request and response objec=
ts.
from Products.PythonScripts.standard import html_quote
request =3D container.REQUEST
RESPONSE =3D  request.RESPONSE

def addPythonScript(obj,id):

  manage_addPythonScript(obj,id)

try:
  j=3Dcontext.objectIds('Script (Python)')
  k=3Dj.index('getTableDetailsStatic')
  print 'Found',k
  print  context.objectValues('Script=20
(Python)')[k].absolute_url(relative=3DNone)
  print   context.absolute_url(relative=3DNone)
  if context.objectValues('Script (Python)')[k].absolute_url(relative=3DN=
one) =3D=3D=20
\
     context.absolute_url(relative=3DNone)+"/getTableDetailsStatic":
    print 'Defined'
  else:
    print 'Undefined'
    a=3Dcontext.manage_addPythonScript('getTableDetailsStatic',REQUEST=3D=
None)
except:
  print 'Not Found'
  addPythonScript(context,'getTableDetailsStatic')

return printed


System:

Zope Version=20
(Zope 2.5.1 (binary release, python 2.1, linux2-x86), python 2.1.3, linux=
2)=20
Python Version=20
2.1.3 (#1, Apr 15 2002, 11:13:45) [GCC 2.7.2.3]=20
System Platform=20
linux2=20
SOFTWARE_HOME=20
/home/usr/local/src/Zope/lib/python=20
INSTANCE_HOME=20
/home/usr/local/src/Zope=20
CLIENT_HOME=20
/home/usr/local/src/Zope/var=20
Process Id=20
1998 (4101)=20
Running For=20
43 days 12 hours 15 min 55 sec=20

Traceback:


<!--
Traceback (innermost last):
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 15=
0, in=20
publish_module
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 11=
4, in=20
publish
  File /home/usr/local/src/Zope/lib/python/Zope/__init__.py, line 159, in=
=20
zpublisher_exception_hook
    (Object: Administration)
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 98=
, in=20
publish
  File /home/usr/local/src/Zope/lib/python/ZPublisher/mapply.py, line 88,=
 in=20
mapply
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 39=
, in=20
call_object
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/Shared/DC/Scripts/Bindings.py,=
 line=20
252, in __call__
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/Shared/DC/Scripts/Bindings.py,=
 line=20
283, in _bindAndExec
    (Object: test)
  File=20
/home/usr/local/src/Zope/lib/python/Products/PythonScripts/PythonScript.p=
y,=20
line 302, in _exec
    (Object: test)
    (Info: ({'script': &lt;PythonScript instance at 8ff9208&gt;, 'context=
':=20
&lt;Folder instance at 8f0af98&gt;, 'container': &lt;Folder instance at=20
8deab20&gt;, 'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 2, in test
  File /home/usr/local/src/Zope/lib/python/AccessControl/ZopeGuards.py, l=
ine=20
144, in guarded_import
  File /home/usr/local/src/Zope/lib/python/AccessControl/SecurityManager.=
py,=20
line 83, in validate
  File=20
/home/usr/local/src/Zope/lib/python/AccessControl/ZopeSecurityPolicy.py, =
line=20
157, in validate
TypeError: (see above)
<!--
Traceback (innermost last):
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 15=
0, in=20
publish_module
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 11=
4, in=20
publish
  File /home/usr/local/src/Zope/lib/python/Zope/__init__.py, line 159, in=
=20
zpublisher_exception_hook
    (Object: Administration)
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 98=
, in=20
publish
  File /home/usr/local/src/Zope/lib/python/ZPublisher/mapply.py, line 88,=
 in=20
mapply
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/ZPublisher/Publish.py, line 39=
, in=20
call_object
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/Shared/DC/Scripts/Bindings.py,=
 line=20
252, in __call__
    (Object: test)
  File /home/usr/local/src/Zope/lib/python/Shared/DC/Scripts/Bindings.py,=
 line=20
283, in _bindAndExec
    (Object: test)
  File=20
/home/usr/local/src/Zope/lib/python/Products/PythonScripts/PythonScript.p=
y,=20
line 302, in _exec
    (Object: test)
    (Info: ({'script': &lt;PythonScript instance at 8ff9208&gt;, 'context=
':=20
&lt;Folder instance at 8f0af98&gt;, 'container': &lt;Folder instance at=20
8deab20&gt;, 'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 2, in test
  File /home/usr/local/src/Zope/lib/python/AccessControl/ZopeGuards.py, l=
ine=20
144, in guarded_import
  File /home/usr/local/src/Zope/lib/python/AccessControl/SecurityManager.=
py,=20
line 83, in validate
  File=20
/home/usr/local/src/Zope/lib/python/AccessControl/ZopeSecurityPolicy.py, =
line=20
157, in validate
TypeError: (see above)