|
|
||||||||||||||||||
|
|
||||||||||||||||||
![]() |
![]() |
Version 1.0 / October 4, 2003
|
|||
|
Moving a Website to Zope - Migrating or using existing HTML based website in Zope - - - - - - - - - - - - By Kristoph Kirchner | October 4, 2003 Introduction
This MiniGuide is meant for Zope beginners who need to import an existing HTML-based Website into Zope without losing the existing code. It will show different ways of moving a Website to Zope, either by importing the content into the ZODB (Zope Object Database) or by keeping it in the file system. The first step in moving a Website to Zope is to decide whether you wish the Web pages, images and so on to reside in the file system or within the ZODB as objects. Depending on the type of file and your intentions with respect to editing the content, both options have their advantages and disadvantages. Some of the possibilities described here require you to copy the Website to the server your Zope server is installed on, while others can work with your Website while it remains on a remote server. Keeping the Files in the File SystemSome files are better stored in the file system, e.g. large movie files. And if you do not wish to edit your Webpages using the Zope Management Interface, you may decide to store your complete Website in the file system. This may be the case, for example, if you only want to keep your Website up while working on a new one but wish to have everything on one server. After finishing the new Website, you will then be able to effortlessly switch from old to new. LocalFS and StreamingFSLocalFS is a Zope product which allows you to access directories and files on the file system via the Zope Management Interface. By creating a LocalFS object, the corresponding file system directory is made available, listing the files as Image, Folder or File objects. The objects can, to some extent, be edited. Though HTML files are represented as DTML Documents and may contain DTML-tags, creating new DTML Documents in the LocalFS object will result in their being created as File objects which do not understand DTML. Therefore, the LocalFS product will not be an option for you if your goal is to turn your, possibly static, Web pages into dynamic Zope objects. StreamingFS is a patched version of LocalFS which uses a Virtual Streamer to emulate object types and provide a stream rendered from the file system. It is suitable for large files and images that would otherwise use up large amounts of RAM. According to the author this product is relatively untested and therefore should be used with caution. Conclusion: These products provide the easiest way to quickly integrate a Website into Zope although they have restrictions on editing the content. These Zope products can be downloaded from: http://sourceforge.net/projects/localfshttp://www.zope.org/Members/johanc/StreamingFS Storing the Files in the ZODB One reason for storing the files in the ZODB could be that you wish to edit the Web pages directly, turning them into Page Templates or DTML Documents. Another reason might be that you wish to keep everything together so that backing up the Zope server or moving it to another location is easy since only the ZODB file data.fs is needed for this. FTP and WebDAV are ways to import a Website into the ZODB without having to move the files first to the server Zope is installed on (the latter is the case, for example, with FSImport and Ape, which are described below). FTP and WebDAVIn order to be able to use FTP or WebDAV with Zope, you will have to make the ports for these protocols available. The ports are opened when Zope is started and they are defined in the Zope start script. See the file z2.py in your Zope installation for details on how to add ports and other options to your start script. There is an extensive description about authoring content with WebDAV and FTP by Jeffrey Shell, which can be found at: http://www.zope.org/Documentation/Articles/WebDAVConclusion: FTP and WebDAV are easy ways to import content into Zope but are both a bit restricted (this is explained in the Shell article).. FSImportFSImport is a Python script written by Mike Pelletier. It recursively goes through the files and subdirectories of a local file system directory and adds them to the ZODB as DTML Methods, File objects, images or folders depending on their content type. To use this script for importing a Website, put it into the Extensions folder of your Zope installation and create an External Method using the method fsimport from the script. Afterwards, you can call the External Method from a script within Zope, for example, or from a DTML Method, giving the directory path of the file system which is to be imported into Zope. The imported objects will retain their hierarchical structure and will be added to the Zope folder from which the method fsimport is invoked. Conclusion: This way of importing a Website into Zope is very easy and efficient. The Python script fsimport can be downloaded from: http://www.zope.org/Members/MikeP/fsimportOther Ways of Integrating a Website into Zope Ape stores a Website in the file system of the server Zope is installed on and imports it into the ZOBD at the same time, while the Zope product HTTPMounter makes a remote Website or part of a remote Website available within the Zope server. Ape (Adaptable Persistence)Ape allows you to keep objects in Zope as well as in the file system or in a database. The Website files first need to be moved into the file system on the server Zope is installed on, in their own directory. Using the file dbtab.conf, which comes with Ape, you can then configure this directory as follows to be represented in Zope as a Folder object: [Storage: OldWebsite] type=apelib.zodb3.storage.ApeStorage factory=apelib.zope2.mapper.createFSMapper basepath=%(CLIENT_HOME)s/ [Database: OldWebsite] class=apelib.zodb3.db.ApeDB cache_size=0 mount_paths=/OldWebsite container_class=OFS.Folder.Folder OldWebsite is a user-defined name; it must be the same for both the "Storage" and the "Database" definition. The variable basepath is the path to the Website directory which in this case lies in Zope's var directory (CLIENT_HOME). The mount_paths variable defines the path within the ZODB. As soon as the Zope server is restarted, the files and folders in the Website directory are shown as objects in the Zope Management Interface. Each object is stored in the file system in three files containing the content of the object, its properties, and the remaining data concerning the object. If new files are added to the file system, they can be accessed via the Zope Management Interface after a refresh. Objects added over the Zope Management Interface are automatically stored in the file system when they are saved. Conclusion: This way of integrating a Website into Zope is the most versatile of the methods mentioned so far since the objects are accessible both in Zope and in the file system. The latest version of Ape can be downloaded from: http://hathaway.freezope.org/Software/ApeHTTPMounter HTTPMounter is a Zope product that lets you mount a remote HTTP server in a local Zope instance. If you wish to keep your Website on your old (non-Zope or Zope) server but want to begin working on a (new) Zope server, making the original Website available on this server as well, HTTPMounter is for you. After adding an HTTPMounter object to your Zope server and giving it the URL of the remote server and subdirectories, you can call the objects on the remote server. Conclusion: Editing the HTTPMounter object's settings is a little unstable and with some servers this product does not seem to work. The product needs some tweaking and is not suitable for a beginner.
HTTPMounter can be downloaded from: http://www.zope.org/Members/ajung/HTTPMounterPHP If you programmed your Website using PHP you will not be able to move it to Zope without a workaround since currently Zope cannot deal with PHP scripts. Here you will find a description of how to serve PHP code stored in the file system as well as in the ZODB: http://www.zope.org/Members/Mamey/PHPFor the methods described in this article a Web server is required that can serve both Zope and the PHP/Perl tree, e.g. Apache.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZopeMag is committed to bringing you the best in Zope Documentation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
Reproduction of material from any of ZopeMag's pages without prior written permission is strictly prohibited. Copyright 2003 - 2005 ZopeMag |
|