[Zope] Uploading a File and getting the files list from Zope

Zope@Stylus zope@stylusinc.net
Mon, 14 Apr 2003 12:50:10 +0530


Hi all
I am working on Zope2.5.1 Page Templates installed on Mandrake Linux 8.3
.The RDBMS I am using is Postgresql-7.2.2.
On going through the examples  that come as apart of Zope Installation I
noticed the python Function addFile
 Script (Python) at  /Examples/FileLibrary/addFile
 This allows a user to add a file to the directory "Files" in the
Examples/FileLibrary Folder.
This folder also has examples of getFiles and getSize getLink
###I am including the   the addFile and getFiles code here ....
----------------------------------------------------------------------------
----------------------------------------
        """addFile(file)
        Adds a file to the library.
         """
        from Products.PythonScripts.standard import url_quote

       # create the file
      container.Files.manage_adProduct['OFSP'].manage_addFile(id='',
title='', file=file)
           ..........................
           ...........................
----------------------------------------------------------------------------
----------------------------------------------
       """getFiles(sort='id', reverse=0)
        Returns a list of files sorted by id, date, type or size.
       """
       files=container.Files.objectValues('File')

        # build arguments for sequence.sort
        if sort=='id':
           if not reverse:
               args=(('getId',),)
           else:
               args=(('getId', 'cmp', 'desc'),)
                 ..............
                 ............................
----------------------------------------------------------------------------
-------------------------------------
In this case the container where the new file or Folder is to be added
("container.Files")  is explicitly stated.So if i call this function from
some other file and try to add a file it again adds a file in the "Files"
container.
I am having a Content management System made  using Zope although not
exactly implementing the full functionality of the CMF.
This System allows a user based on permisions to add Folders and files which
can be viewed by others.
The problem here is that when a folder is added I will need to include by
default the addFile,getFiles,getSize,getLink (Examples Folder at Root of the
Zope Installation Web Interface)
 python scripts in all New
folders added by a user.That means 4 new files have to be added to a new
Folder everytime I add a folder. These four Python Scripts will have to be
aded dynamically when i create a new Folder so that if I add it will accpet
the current conatiner as the default container for adding a file into.I am
not sure how I will be able to change the scripting in the Python files if
necessary at run time either or how to write into or read from a file at
runtime....Anyway that is going away from my problem..... Also if it is
necessary to add a file by default in a folder when a new folder is created
what function can I call??(For e.g if I add a new Folder Object I am asked
if I want a public interface and on saying yes a new Page Temlpate called
index_html is added )

But if I had only these 4 Python Scripts (addFile,getFiles,getSize,getLink )
at the root of my application and i could tell the function when I called
it... in which container to add the file then the whole issue would be
resolved althought I dont know how to.. By sending the conatiner path as a
string it is not going to work because the adFile,getFile scripts expects a
Container Object.
Can you suggest how I can keep the four files at the Root of my application
and keep adding files in to any of the Subfolders by passing the reference
of that particular subFolder or container.I am sure that there is some way
to do it.But I dont know how.. Please help me out.

Thanks and Best regards
John Kunchandy



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 3/25/2003