[Zope] Can't open file via Python

Geoff Armstrong geofstro@monaco.mc
Thu, 29 Mar 2001 10:49:14 +0200


--============_-1226266739==_ma============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Hi,

I want to open and read a file via Python; but whether I try to do it 
via a Python method or an external Python script stored in the Zope 
extensions folder, the result is the same.

I'm using this code for a file name I pass in as a parameter:

data = open(file, 'r')
return data


...and I get this result:


Error Type: NameError
Error Value: open

The Python method has a proxy role of Manager and so does the DTML 
script which calls it.

The same thing happens when I try read or readline. I know Python 
methods are limited in certain ways; but external scripts?

Please help



Thanks


Geoff Armstrong
--============_-1226266739==_ma============
Content-Type: text/html; charset="us-ascii"

<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { margin-top: 0 ; margin-bottom: 0 }
 --></style><title>Can't open file via Python</title></head><body>
<div>Hi,</div>
<div><br></div>
<div>I want to open and read a file via Python; but whether I try to
do it via a Python method or an external Python script stored in the
Zope extensions folder, the result is the same.</div>
<div><br></div>
<div>I'm using this code for a file name I pass in as a
parameter:</div>
<div><br></div>
<div>data = open(file, 'r')</div>
<div>return data</div>
<div><br></div>
<div><br></div>
<div>...and I get this result:</div>
<div><br></div>
<div><br></div>
<div><font face="Times New Roman" size="+3" color="#000000"><b>Error
Type: NameError</b></font></div>
<div><font face="Times New Roman" size="+3" color="#000000"><b>Error
Value: open</b></font></div>
<div><font face="Times New Roman" size="+3"
color="#000000"><br></font></div>
<div>The Python method has a proxy role of Manager and so does the
DTML script which calls it.</div>
<div><br></div>
<div>The same thing happens when I try read or readline. I know Python
methods are limited in certain ways; but external scripts?</div>
<div><br></div>
<div>Please help</div>
<div><br></div>
<div><br></div>
<div><br></div>
<div>Thanks</div>
<div><br></div>
<div><br></div>
<div>Geoff Armstrong</div>
</body>
</html>
--============_-1226266739==_ma============--