[Zope] Calling External Method...

Chris McDonough chrism@digicool.com
Sun, 21 May 2000 12:00:42 -0400


> EEK!  You're right!  OK, that's fixed for now, but I thought 
> I saw in this
> mailing list that an external method was required to have a 
> docstring.  What
> role does the docstring play, exactly?  My ultimate goal is 
> to be able to
> run the C++ program from Zope, returning the results to a 
> Zope generated web
> page.  In your opinion, what's the best way to do that?

I think the way you're doing it is fine unless you expect it to be hit a
lot or it becomes too slow.  If you leave the docstring off the external
method, you can still call it from DTML, but you can't call it from the
web.  This only really helps if nobody else has access to write DTML on
your site.  It's probably most wise to just make an external method
called websim that just runs that specific executable instead of running
an arbitrary executable chosen by the DTML programmer, in case someone
can somehow add DTML to your site, or in case someone finds a hole.

> //
> // > 
> /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)
> //
> // I *think* this error message is telling you that it can't 
> format the
> // status code as an integer in your raise statement.  Why 
> don't you take
> // out your status checking code and see what happens.
> I tried taking out the status code stuff and it didn't help.
> 
> Am I on the right track with this?  Shouldn't it be easy (& secure) to
> launch a C app on the server and pipe the results back to 
> Zope?  If so, how.
> The approach I took (above) was recomended by someone else on 
> the list.

I think you should  probably make sure the function works from Python
(unless you already have).  Use an absolute path to the executable, as
your cwd may change inside of Zope.  Then when you're able to import the
Python module that makes up the external method module and execute the
function successfully, make it an external method within Zope.