[Zope] Make os.popen() available to scripts

Simon Forster simon-lists at ldml.com
Mon Aug 9 10:55:40 EDT 2004


I would like to make os.popen() available to python scripts added via 
the Zope management interface [1]. Following a previous posting, people 
pointed me to zope/lib/python/Products/PythonScripts/README.txt and 
Paul Winkler added to that a URL 
<http://www.zopelabs.com/cookbook/1074897091>.

Following the README all I need do is create an __init__.py file with 
the content:

from Products.PythonScripts.Utility import allow_module
allow_module('os.popen')

in an appropriate products folder. As this got me nowhere I dug around 
and found that "# These have been relocated, and should be imported 
from AccessControl" so I modified this to:

from AccessControl import allow_module
allow_module('os.popen')

This I've done and indeed, I have the appropriate product listed in the 
Control Panel. When I call my testScript, it all works fine up to:

return popen(cmd_str).read()

Where cmd_str is a valid string which has been run in a standalone 
python environment. When I uncomment this line I get endless requests 
for a username:password pair from the browser.

Quite obviously I'm doing something wrong. At this point in time I do 
not understand Zope at all and the more I read, the more confused I get 
:-(

Can someone point me in the right direction?

Many thanks

Simon Forster
_____________________________________________________
  LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
  Tel: +44 (0)70 9230 5244   Fax: +44 (0)70 9230 5247
_____________________________________________________

[1] Actually, I don't care where I call os.popen() from. I've played 
with external scripts and started down the road of futzing with a 
product to do this. However, the simplest approach seems to be the one 
I following at the moment. Once I can get this working, hopefully I can 
progress in other areas.



More information about the Zope mailing list