[Zope] Re: Python Method

Loren Stafford lstaffor@dynalogic.com
Thu, 10 Feb 2000 07:53:37 -0800


Please direct your questions to the Zope mailing list so that others can
benefit from the discussion. But not everyone can process HTML in their
mail; so better to send plain text.

Python Methods are like External Methods in that they are both written in
pure Python.

Python Methods are not like External Methods in that the Python Methods are
restricted as to the Python modules and constructs that can be employed. The
only constructs permitted are those that are "safe" for storing in the Zope
database. External Methods, because they reside in the file system are
subject to the stronger security of the operating system, therefore they are
permitted to use all Python constructs.

You cannot access the file system through Python Methods; you must use
External Methods.

-- Loren
  ----- Original Message -----
  From: Pedro Silva
  To: Chris McDonough - Zope
  Cc: Pavlos Christoforou - Zope ; Loren Stafford - Zope
  Sent: February 10, 2000 03:46 AM
  Subject: Python Method


  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.

  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 = 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=lines
       return from

  Is this code correct?

  Thanks,

  Pedro

  PS - I have send this question to zope, too