DurusWorks Documentation

DurusWorks is a web application framework that brings together the key tools developed at the MEMS and Nanotechnology Exchange at Corporation for National Research Initiatives. At CNRI, the current maintainer of DurusWorks is Roger Masse.

Standard Installation

There are many ways to install and use DurusWorks. Rather than try to describe all of the options, we will describe the way we choose to install and use DurusWorks on the OSX and Linux machines. We will refer to this arrangement as a "standard installation".

In the standard installation, we put almost everything under a /www directory. You can use another directory name if you like, but we'll assume throughout these documents that your installation is all under /www. To get started, log in as root and execute these commands to make the standard directories (which we assume do not already exist). mkdir /www mkdir /www/trunk mkdir /www/pythonlib mkdir /www/bin mkdir /www/var; chmod 777 /www/var mkdir /www/qp_sites mkdir /www/ssl mkdir /www/cgi-bin mkdir /www/conf

The subdirectories are populated as follows:

This directory contains the files and python code that we use, including the DurusWorks distribution. Download the current DurusWorks distribution tarball and unpack it in /www/trunk. The DurusWorks created by unpacking the tarball may have a version number suffix. Rename the directory to remove the suffix. Next, compile and install in-place the DurusWorks C-extension modules by doing this: cd /www/trunk/DurusWorks python setup.py build_ext -i rm -r build

While we are working in /www/trunk, go ahead and install the Apache2 mod_scgi module by doing this: cd /www/trunk/DurusWorks/scgi sudo make install; sudo make clean

This directory is put on python's search path, either by the PYTHONPATH environment variable, or by other means. You may, for example, edit your .profile to include this: export PYTHONPATH=/www/pythonlib

To initialize this directory, do this: cd /www/pythonlib sudo ln -s /www/trunk/DurusWorks/durus . sudo ln -s /www/trunk/DurusWorks/qp . sudo ln -s /www/trunk/DurusWorks/qpy . sudo ln -s /www/trunk/DurusWorks/sancho .

This directory is included in the developer's PATH environment variable. It contains symlinks to command-line tools in the trunk. You may, for example, edit your .profile to include export PATH=/www/bin:$PATH

To initialize this directory, do this: cd /www/bin sudo ln -s /www/trunk/DurusWorks/durus/durus . sudo ln -s /www/trunk/DurusWorks/qp/bin/qp . sudo ln -s /www/trunk/DurusWorks/qp/bin/qpcensus.py . sudo ln -s /www/trunk/DurusWorks/qpy/qpcheck.py . sudo ln -s /www/trunk/DurusWorks/qpy/qpyrun.py . sudo ln -s /www/trunk/DurusWorks/sancho/urun.py .

This directory, which must be writable by the owner of the running server process, keeps all durus database files, logs, and pid files. If the application stores any data outside the database, it is in some subdirectory of this directory. In the standard installation, all sites have var_directory='/www/var in the SitePublisher.configuration dictionary.
This directory contains symlinks to the site directories of all active sites.

Let's set up the site called proto. To initialize the demo site and this directory, do this: sudo cp -r /www/trunk/DurusWorks/proto /www/trunk/proto cd /www/qp_sites sudo ln -s /www/trunk/proto/site proto cd /www/pythonlib sudo ln -s /www/trunk/proto/lib proto

This directory contains the ssl certificate/key files for your server. If you need to generate a self-signed certificate for development purposes, try this command: sudo openssl req -new -x509 -nodes -days 365 -out /www/ssl/self.pem -keyout /www/ssl/self.pem
This directory contains any cgi-scripts that your server may require. There may not be any.
This directory contains Apache web server configuration files. We either replace the standard /etc/apache2/httpd.conf file with a symlink to a complete Apache config here, or else we append an directive to the standard httpd.conf that includes the contents of a file in this directory.

For the proto demo application, append Include /www/conf/apache2_proto.conf to /etc/apache2/httpd.conf and also do this: ln -s /www/turnk/proto/conf/apache2_proto.conf /www/conf/apache2_proto.conf

In the standard installation, the applications are also defined in packages in the /www/trunk directory. To provide an example of how we organize the code for an application, we'll describe the parts of the demo site called proto.

This contains the files that define the proto site.
This contains the proto python package. In the standard installation, /www/pythonlib contains a symlink named proto that points to this directory. This directory typically contains python modules and subpackages that define the data structures and business logic of the site.
This contains part of the proto specifically related to defining the URL space and constructing web pages. All .qpy files for the site are in this directory or subpackages of it. As with all packages that contain .qpy files, the __init__.py file must contain the commands to run the compiler: from qpy.compile import compile_qpy_files compile_qpy_files(__path__[0]) This directory contains a slash.qpy that defines SitePublisher and SiteDirectory classes. These classes define the site's configuration.
This directory contains the static content of the site. It is declared as the DocumentRoot of the site in the Apache configuration.
The static images of the site are placed in this directory.
This contains an empty __init__.py and a slash.py with this one line: from proto.ui.slash import import SitePublisher, SiteDirectory
Site-specific documentation is placed here.
Site-specific Apache configuration files are placed here. Symlinks to these files are placed in /www/conf