[Zope] - External Method questions

Amos Latteier amos@aracnet.com
Thu, 10 Dec 1998 12:41:06 -0800


At 10:00 AM 12/10/98 -0800, David Ascher wrote:
>* I'd like to add an external method in a Shared package, but I'm not sure
>  how to do it -- in the Add External Method form, what's the "module
>  name", is it packagename.modulename, packagename/modulename, or what?
>  I've tried various combinations with no luck.

I don't think you can add an external method from the Shared package...

>* I want to return an image from my external method.  What I have
>  which sort of works is:
>
>	def foo(self, RESPONSE):
>	    RESPONSE['content-type'] = 'image/png'
>	    return mkimage()
>
>  where mkimage returns the actual PNG image data.  Is this correct?

Sure. You can also use RESPONSE.setHeader('content-type','image/png')

>* How can an external method refer to the objects in the Zope app?
>  'self' above is App -- can I do App.foo and get to object foo?

Right. self is your hook into Zope world. From self you should be able to
get anywhere you'd like to go. Just to be clear, self is the folder in
which the external method is called. External Methods are methods of
Folders. Since External Methods are acquired, self is not always the same
Folder in which the method is defined--it may be a child Folder. Make sense?

>* Is there a way for external methods to read from files on the
>  filesystem?  How about write to files on the filesystem?  What kinds of
>  sandbox is in place?

Right now there is no sandbox or restricted execution environment for
External Methods. You can do literally anything that you normally do in
Python. So you have the power to do both great good and great evil. This
power is one reason that External Methods are required to be defined in the
Extensions directory--it's easier to keep an eye on them there.

-Amos