[Zope] Calling External Method...
Eric L. Walstad
Eric@Walstads.net
Sat, 20 May 2000 18:49:56 -0700
I am trying to invoke a C++ program from an external method. Platform is
Linux. The C++ program returns HTML. Note that the Python function is
working properly from the Python command line; That is,
ExecCGI.xCGI("./websim") outputs all the expected html. I have placed the
C++ program in the same folder as the ExecCGI module. The C++ program works
from apache: here's an example of the program's output, which is what I'm
trying to get into Zope:
http://63.203.42.146/cgi-bin/websim
ExecCGI module:
import sys, os, string
def xCGI( cmdLine ):
"""
Run an external command and return its standard output as a string.
"""
f = os.popen( cmdLine )
lines = f.readlines()
status = f.close()
if status:
raise "CGI returned error: %d" % status[1]
return string.join( lines )
External Method that calls the C++ program:
Id ExecCGI
Title Test
Function name xCGI
Python module file (without suffix) ExecCGI
DTML Method that calls the External Method:
<dtml-var standard_html_header>
<h2><dtml-var title_or_id></h2>
<dtml-let cmdLine="'./websim'">
<dtml-var "ExecCGI(cmdLine)">
</dtml-let>
<dtml-var standard_html_footer>
Traceback:
Traceback (innermost last):
File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 214, in
publish_module
File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 179, in
publish
File /usr/local/Zope/lib/python/Zope/__init__.py, line 202, in
zpublisher_exception_hook
(Object: ElementWithAttributes)
File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 165, in
publish
File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: TestWS)
File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 102, in
call_object
(Object: TestWS)
File /usr/local/Zope/lib/python/OFS/DTMLMethod.py, line 150, in __call__
(Object: TestWS)
File /usr/local/Zope/lib/python/DocumentTemplate/DT_String.py, line 502,
in __call__
(Object: TestWS)
File /usr/local/Zope/lib/python/DocumentTemplate/DT_Let.py, line 145, in
render
(Object: cmdLine="'./websim'")
File /usr/local/Zope/lib/python/DocumentTemplate/DT_Util.py, line 335, in
eval
(Object: ExecCGI(cmdLine))
(Info: ExecCGI)
File <string>, line 0, in ?
File /usr/local/Zope/lib/python/Products/ExternalMethod/ExternalMethod.py,
line 248, in __call__
(Object: ExecCGI)
(Info: (('./websim',), {}, None))
File /usr/local/Zope/Extensions/ExecCGI.py, line 11, in xCGI
TypeError: (see above)
File Permissions in /usr/local/Zope/Extensions/:
-rwxr-xr-x 1 ewalstad users 318 May 20 17:31 ExecCGI.py
-rw-r--r-- 1 ewalstad users 576 May 20 17:03 ExecCGI.pyc
-rwxr-xr-x 1 ewalstad users 336081 May 20 17:13 websim
Any help is GREATLY appreciated!
Thanks,
Eric.