[Zope] Python Method

Pedro Silva Pedro Silva" <pedro.silva@ruido-visual.pt
Thu, 10 Feb 2000 11:45:34 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_0007_01BF73BC.57876480
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Someone has told me that if I wanted to access object in the filesystem, =
I had to use External Methods instead of use the local filesystem Zope =
Product.

When I was seeing something in python, to can write the code, I went to =
the zope page and I discorery a Product that is like the External =
Method, that product was the Python Method that let us write the code =
python and let us access to the filesystem as the same way as the =
External Method.

What I wanted is that, if someone as tryed this product, or External =
Method, because the code un Python is the same, if can help me in one =
thing.=20

I have one folder in the filesystem that I want to access. I'm using the =
OPEN, to can open the folder and I want to read the content of that =
folder. The code line is like:

       f =3D open('var/spool/news/articles','r')

But unfortanelly, when I reun this and the rest of the code, it gives me =
a Syntax Error. I think that the error may be in this code line, because =
the otherones are correct. Can anyone tell me a way to access the =
content of the folder access?

The other problem that I have is, I want to search in some text, that it =
is too in the filesystem, for some words. For example: I want to find in =
that file, the word From: and when he founds the word, he has to write =
the text after to a variable. The code that I'm using is:

     for lines in f.readline():
          if string.find(line,'Form:'):
                 from=3Dlines
     return from

Is this code correct?

If anyone could help me, that would be great!!! This is urgent, please =
send your answer to: psilva@ruido-visual.pt

Thanks,

Pedro Silva


------=_NextPart_000_0007_01BF73BC.57876480
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Someone has told me that if I wanted to =
access=20
object in the filesystem, I had to use External Methods instead of use =
the local=20
filesystem Zope Product.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>When I was seeing something in python, =
to can write=20
the code, I went to the zope page and I discorery a Product that is like =
the=20
External Method, that product was the Python Method that let us write =
the code=20
python and let us access to the filesystem as the same way as the =
External=20
Method.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What I wanted is that, if someone as =
tryed this=20
product, or&nbsp;External Method, because the code un Python is the =
same, if can=20
help me in one thing. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have one folder in the filesystem =
that I want to=20
access. I'm using the OPEN, to can open the folder and I want to read =
the=20
content of that folder. The code line is like:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f =
=3D=20
open('var/spool/news/articles','r')</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>But unfortanelly, when I reun this and =
the rest of=20
the code, it gives me a Syntax Error. I think that the error may be in =
this code=20
line, because the otherones are correct. Can anyone tell me a way to =
access the=20
content of the folder access?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The other problem that I have is, I =
want to search=20
in some text, that it is too in the filesystem, for some words. For =
example: I=20
want to find in that file, the word From: and when he founds the word, =
he has to=20
write the text after to a variable. The code that I'm using =
is:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; for lines in=20
f.readline():</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if=20
string.find(line,'Form:'):</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
from=3Dlines</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; return =
from</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Is this code correct?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If anyone could help me, that would be =
great!!!=20
This is urgent, please send your answer to: <A=20
href=3D"mailto:psilva@ruido-visual.pt">psilva@ruido-visual.pt</A></FONT><=
/DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Pedro Silva</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0007_01BF73BC.57876480--