[Tutor] Problem with a simple External Method in ZOpe

Karthik Gurumurthy karthikg@aztec.soft.net
Mon, 8 Apr 2002 15:40:44 +0530


> Hi Karthik,

> Hmmm... You may want to check file permissions, just in case.  Zope runs
> as the user who started it, so if the directory doesn't allow the Zope
> user to write to it, you should see an IOError.
> 
> If you can show us the code for the external method, we can try it on our
> end and see what's going on.  Also, how are you calling the external
> method?

> Finally, you might also want to send your question to the Zope user's
> list:

>     http://lists.zope.org/mailman/listinfo/zope

> It's high volume, but it should be useful for you.

hi Danny,
This is the simple code snippet:

def sayHello():
    retVal = "" 
    try:
        fp = open("test.txt","w")
	  fp.write("Zope scripts\n")
        fp.write("Python\n")
        fp.close()
        retVal = "success"
    except IOError,e:
        retVal = "failure"
    return "hello " + str(retVal)

if __name__ == '__main__':
    print sayHello()

tested my script using the "test" tab on the top of the external method 
			AND
accessed it through this URl as well.

http://localhost:8080//id_test/id_new/id_py_file/hello

I can see "hello success" getting printed.

regards
karthik.