[Zope] Reading and Writing Files

Andreas Lauser and@poware.org
Wed, 26 Jun 2002 15:29:29 +0200


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 25 June 2002 18:49, Roberto Rivero wrote:
> Hi I'm a bit of a Zope newbie and I've been scouring various documentat=
ions
> on how to open and print the contents of a file using a python script.

hmm. I'm not sure what you exactly mean by the term 'file'. I think you m=
ean=20
an object in the zope database (ZODB).=20

to  create an object in the ZODB try this:

- --------- snip ---------
# create a new file object
container.manage_addProduct["OFSP"].manage_addDTMLMethod("myDtml",title=3D=
"myTitle")

# push some data into it
container.myDtml.manage_edit("hello, world", container.myDtml.title)

# print the data
print container.myDtml()

return printed
- --------- snap ---------

note that you created an object called DTML method. You may need other ki=
nds=20
of objects, depending on your task...=20


> I tried the following code but it didn't work:
> fd =3D context.open('file','r')
> print fd
>
> I get an AttributeError.

Access to the 'real' filesystem is from zope limted for security reasons.=
 if=20
you _really_ need access to the filesystem you have to create an 'externa=
l=20
method'.

mfg
  AND

- --=20
I doubt, therefore I might be.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9GcG5hlekfiEFJv4RAt91AKCSWuWEnVqfdrl9h7w7/Pvow27eVQCgyvVb
j1jtNgPd1r/PERrMIC9wa9A=3D
=3DnYHz
-----END PGP SIGNATURE-----