fsimport.py defines a couple different functions to accomplish its work. The main function which is actually bound to the Folder is 'fsimport'.
def fsimport(self, fsdir, REQUEST=None):
"""Import a filesystem directory as a new folder object into
raise ValueError, 'Path does not exist'
return MessageDialog(title='Directory imported.',
message='Directory imported.',
action='%s/manage_main' % REQUEST['URL1']
This method accepts a file system directory as an argument. The REQUEST argument is automatically supplied by Zope. The first thing the method does is check to see if the directory exists. If it does exist, the method calls the 'rcimport' function. Finally it returns a confirmation message if called through the Web.
The 'rcimport' function does most of the work of sifting through the file system and creating Zope objects to match the files it finds
pathname=os.path.join(fsdir, name)
if name[0] in ('.', '#', '_'):
elif os.path.isfile(pathname):
obdir.manage_addDocument(name, '', data)
obdir.manage_addImage(name, data)
fobj=File(name, '', data, content_type=_ftype(pathname))
rcimport(pathname, getattr(obdir, name))
__traceback_info__=(fsdir, obdir, name)
.Basically how this function works is that it gets a list of files within a given directory, tests them against criteria and then creates Zope objects to match. Its two arguments are 'fsdir' which is the file system directory to comb through and 'obdir' which is the Zope Folder to add Zope objects to. The first thing the function does is reject some files based on their names. Next is tests the files to determine if they are DTML Documents, DTML Methods, Images, other Files or Folders. In each case to create a Zope object, first a Zope object is created, and then a method of 'obdir' is called to place the object in the current Zope Folder. In the case of Folders, the function calls itself to recursively import the contents of the Folder.
1. Some installations of Zope may contain, in addition to the standard objects, a public interface. If this is the case, the index_html DTML Method will need to be deleted in order to add a new public interface (For information on deleting Zope objects, see Working with Objects).
2. DTML Methods can display their own standard Zope properties, id and title. Within a DTML Method, <!--#var document-title--> displays the DTML Method's title, and <!--#var document-id--> displays its id.
3. See "Creating Folder" in the "Quick Start Tutorial". Note that the Folder name, "News" was used for the Public Relations department.
4. Python is a high-level object-oriented programming language. To find out more about Python, visit http://www.python.org , or look at one of the many books on the language.
5. Modules can also be written in C or in programming languages callable from C, such as C++ or Fortran. Modules can also use distributed protocols, such as CORBA, ILU, or COM.
6. Note, to identify new_logo as a file upload, it is given the type file. In order to send file uploads, the Designer form must be configured with the attribute, ENCTYPE = "multipart/form-data".
7. The distribution file is a GNU zipped tape achieve (tar) file. Products are "installed" by simply extracting the distribution file in a Zope installation.
8.
The exact system command used to extract a product distribution file depends on your system. On Unix systems, use the command:
gunzip <distribution-file | tar xovf -
On windows system, use a utility such as Nico Mak Computing's WinZip.
9. External methods are objects provided in the Zope developers pack that allow Zope to be extended with functions written in Python.
10. Pluggable brains are classes written in Python that can be used to provide extra behavior to data returned from searches using products, such as Aqueduct and Zope Network Clients.
Previous Chapter | Up | Contents