Hi Everyone, 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 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; 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. Thanks, Chris
Hi Chris, first: please use only plain text for mailinglist. Most people dont like html text there. Zopes DTML and Python Script Objetcs are in a security sandbox for good reason. (see the documentation for the reasons, they are explained in great detail) However, if you _really_ nead to access a file in the filesystem, you have to use an external method. For security reasons dont use the filename as a parameter for this function or only after excessive testing of the name. HTH Tino Wildenhain --On Monday, November 12, 2001 11:56:29 -0700 csnorville@fedex.com wrote:
Hi Everyone,
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 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;
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.
Thanks,
Chris
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
participants (3)
-
csnorville@fedex.com -
Jason Earl -
Tino Wildenhain