[Zope] File I/O in Zope
Jason Earl
jason.earl@simplot.com
12 Nov 2001 12:13:55 -0700
csnorville@fedex.com writes:
> Hi Everyone,
Hello
> I am fairly new to Zope and I need some assitance on something that
> I know is fundamental so please don't beat up on me too bad ;-)
I haven't been a member of this list for too terribly long, but the
folks here seem to be pretty darn friendly.
> I am try to open a file with a Python Script in Zope for content
> manipulation. This is a text file, I basically want to read a
> number, operate on it and write it back out. However when I try to
> get my file handle I get;
You are going to need to use an External Method (or a Product) for
this. The Zope based Python scripts only offer a "safe" subset of
Python. Opening files on the filesystem is not a part of this "safe"
subset.
> file=open("/home/chris/misernumber", "r+")
>
> Zope Error
>
> Zope has encountered an error while publishing this resource.
>
> Error Type: NameError
> Error Value: global name 'open' is not defined
>
> I tried creating the file as a Zope object but I get the same error.
> Again I know this is fundamental. If ya'll can help me with this, or
> at least point me to some documentation it would be deeply
> appreciated.
There probably is a way to do this with Zope objects, but it wouldn't
be using open(). There is a whole slew of methods for manipulating
Zope objects, check the Zope API section in the Zope Book.
Depending on what you are actually trying to do there might be a more
Zope-like way of accomplishing it than with the External Method
hammer, but without knowing what you are trying to do it is hard to
guess what that more Zope-like thing should be.
Jason