Silva and the Filesystem

Meta:

Valid for:  Silva 0.9.3
Author:     Martijn Faassen
Email:      faassen@infrae.com
CVS:        $Revision: 1.4 $ $Date: 2003/11/14 21:31:05 $

Introduction

Silva versions up until 0.8.5 had two main components; the content object code existed as python code on the filesystem, while the view code in the form of page templates and python scripts was stored in the ZODB, and managed through the ZMI. While this separation helped rapid development of Silva in the beginning, this was really starting to hamper Silva development as more developers came in. It was hard to keep the views in sync with the content object code; they could not be checked in silutaneously in CVS. It also made deployment harder than it should be: Silva not only requires the installation of a number of Zope filesystem products but the importing of a .zexp as well. We decided that it would be far easier if all code (including the views) resided on the filesystem.

Another, related problem is that of the packaging of Silva extension products. A Silva extension product contains its own content objects written in Python. These objects have their own views. Due to the way Silva associates views with content objects it was hard to distribute views for extension products separately. Another goal was to make this packaging more easy.

FileSystemSite

Luckily, a large part of the solution already existed. The Zope CMF project has a system for storing code normally stored in the ZODB on the filesystem instead. Files from the filesystem are reflected into the ZODB as normal Zope objects. Kapil Thangavelu has extracted this code from the CMF and bundled it as a separate product called FileSystemSite. Since then, Infrae and Philipp von Weithershausen took over maintenance and it can now be downloaded here:

http://www.zope.org/Members/philikon/FileSystemSite

Silva has been modified so it uses FileSystemSite for its views. In practice this means that many folders have been replaced by a special kind of object called 'DirectoryView'. A DirectoryView reflects a filesystem directory into the ZODB. Files in these directories (and subdirectories) get turned into page templates, python scripts and so on, dependent on their extension ('.pt', '.py'). Since Silva uses Formulator forms, Formulator and Silva have been extended so that forms can also be maintained on the filesystem in an XML format.

Where are things now?

The Silva filesystem product has gained various new directories:

'views' -- This contains the core whole view hierarchy in the form of the filesystem representations of page templates, python scripts, etc. It contains common infrastructure shared by all views in directories higher up, and in the end nodes particular view code for the individual object types that come with the Silva core distribution, such as Document and Folder. Will be installed in the Silva root as 'service_views/Silva'.

'globals' -- This directory contains a lot of images that are used in many places in the Silva Management Interface, as well as stylesheets and other shared UI related code. Will be installed in the Silva root as 'globals'.

The Silva Document product has the following directory:

'widgets' -- This contains the whole widget trees for the XML viewers and editors that come with the Silva Document. Will be installed in the Silva root as 'service_widgets'. (this used to be in the Silva core until SilvaDocument got extracted into a separate product)

Configuration

The configuration and setup code that resided in 'service_setup' has been integrated into the 'install.py' python module. When you create a 'Silva Root' object in the ZMI, its 'installFromScratch' function is called to install and configure all the core services into it. Therefore, installing Silva is now a lot simpler; after installing the filesystem products there's no need anymore for importing a .zexp. Just create a new Silva Root from the ZMI.

Upgrading

Upgrading Silva should be a matter of installing a new version of the Silva filesystem product and restarting your Zope. After that go to the 'service_extensions' and click 'refresh' for Silva to refresh its view bindings.

If you want to see the new default layout templates click the 'install default layout' button. This will create or update the 'default' page templates and python scripts for Silva. You can look at the code there and put it in your own layout templates if you see anything you like.

Upgrading from a 0.8.5 version of Silva to 0.8.6 is possible; follow the instructions in UPGRADE.txt.

Packaging extension products

It is now possible to distribute a tree of views separate from the core views in an extension package. If you register the views using FileSystemSite's 'registerDirectory()' functionality you can then add them as a DirectoryView to the 'service_views' folder in Silva. Look at SilvaDemoExtension for an example of how to set this up (the meat is in the 'install.py' file).

Silva will automatically detect a Silva extension product and it will show up in the 'service_extensions' page. You can click 'install' there to make it install itself. If you changed something in an extension product (or the Silva core for that matter), and you want to reregister it, you can click the 'refresh' button.

Exporting ZODB code to the filesystem

If you have existing view or widgets code you can export this to the filesystem using an external method included in the Silva product directory in 'Extensions/SiteExport.py'. This is a modified version of the module that comes with FileSystemSite that also exports Formulator forms and images. Install this module in the 'Extensions' directory in your Zope filesystem root and create an external method object referring to the 'export_container' function in this module. You can then use this external method to export trees of Zope folders to the filesystem.

Copyright © 2002-2004 Infrae. All rights reserved.
See also "LICENSE.txt" in the Silva package.

OSI Certification Mark Public domain: no rights reserved
Public Domain

Scroll to top of page To table of contents for the site: acc-m Search the site: acc-f To site index: acc-i Find content in the site: acc-f No link