[Zope] open again

Small Business Services toolkit at magma.ca
Thu Jun 3 16:20:43 EDT 2004


Quick and dirty solution:

  fileptr = open('somefile', 'r')              # open file with read access
  instr = fileptr.readline()                    # read a line

Where 'somefile' is the name of the data file that resides in your
.../Extensions directory (same directory as the external method which is
opening the file).

You should get yourself some python documentation.

HTH

Jonathan


----- Original Message -----
From: "Abraham Arellano Tavara" <zinoland at hotmail.com>
To: <zope at zope.org>
Sent: June 3, 2004 4:10 PM
Subject: [Zope] open again


> thanks i'll try to make this real, but i'm new in this i for the things
that
> i read i thought that i can use the command "open" easily, but i see that
is
> not possible..
> I have another question, which is the BASEPATH, the path to the pakage
> YourProject??
> && where goes the last part of code that you show to me?? in the init.py
or
> in a external method in the directory Extensions??
> sorry for these questions... first time in zope..
>
>
> >From: "Passin, Tom" <tpassin at mitretek.org>
> >To: <zope at zope.org>
> >Subject: RE: [Zope] open
> >Date: Thu, 3 Jun 2004 15:44:47 -0400
> >
> > > From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On
> > > Behalf Of Abraham Arellano Tavara
> >
> > > sorry but which files properties are thoses.... and my
> > > original file is in
> > > the directory "Extensions" outside the Zope directory
> > > structure, there i use
> > > the open but i don't know how. Thanks for the help, Abraham.
> > >
> >
> >Your External Method file is in the Extensions folder, which is normally
> >part of your Zope installation's directory tree.
> >
> >Here is an example that I have used successfully.
> >
> >In some other directory, put a file containing the python code that you
> >wish to execute.  For example -
> >
> >Zope
> >    Extensions
> >    ...(other Zope directories)
> >
> >YourProject
> >    __init__.py
> >    YourPythonFile.py
> >    Data
> >
> >The __init__.py file turns that directory into a Python "package".
> >"Data" is a subdirectory.  In the __init__.py file, put code similar to
> >the following -
> >
> >import os.path
> >
> >BASEPATH=os.path.dirname(__file__)
> >DATA_PATH=os.path.join(BASEPATH,'Data')
> >
> >Now put YourProject into the Python path.  There are several ways to do
> >this, but the easiest is to write the absolute path to the directory on
> >one line in a .pth file - say "project.pth".  Put this file into the
> >same directory as  Zope's Python executable.
> >
> >In your external method, place code similar to the following -
> >
> >from YourProject import BASEPATH, DATA_PATH
> >from YourProject import YourPythonFile.YourFunction
> >
> >Now the paths and functions are available to the whatever external
> >method code you wish to write.  I recommend just computing the right
> >directories and calling the module's code, something like this -
> >
> >Import os.path
> >def external_method(filename):
> >    yourPythonFile.yourFunction(os.path.join(DATA_PATH,'data.txt'))
> >
> >Of course, you can pass the REQUEST or whatever else you like as well.
> >
> >Cheers,
> >
> >Tom P
> >
> >_______________________________________________
> >Zope maillist  -  Zope at zope.org
> >http://mail.zope.org/mailman/listinfo/zope
> >**   No cross posts or HTML encoding!  **
> >(Related lists -
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
>
> _________________________________________________________________
> Consigue aquí las mejores y mas recientes ofertas de trabajo en América
> Latina y USA: http://latam.msn.com/empleos/
>
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>





More information about the Zope mailing list