- Python package index entry
- Online documentation: for the latest released version (PyPI), for the development version (Read the Docs)
- Bitbucket project page: source code (Mercurial repository), issue tracker
- License: Zope Public License (ZPL) 2.1
What is Ophelia?
Ophelia is a Python package that assembles XHTML pages from templates. It is used on a web server to generate each page at the moment it is requested.
- Ophelia avoids repetitive code.
- Text and HTML structures common to all pages in a directory are stored in a shared common template. What templates a web page consists of and in which way they are combined follows directly from the URL. Thus, it is not even necessary to write for each page which templates it needs to use.
- Ophelia is dynamic.
- Templates are written in TAL, the Template Attribute Language of Zope. TAL is XHTML with the added possibility to acquire the content of DOM elements and attributes from context variables. The context is modified by Python scripts. A template shares a file with its corresponding script to make for easy handling, but there's still a clean separation of Python code from XHTML content.
- Ophelia works on files.
- All templates and scripts reside in the server's file system. Therefore, one can edit and version-control the contents of one's pages easier than using a relational or object database. On the other hand, one would certainly not want to program complex applications in this manner; Ophelia can't be recommended for anything more than «SSI on drugs».
Ophelia is currently used to serve a few web sites, among them this one. See Powered sites for others.
Using Ophelia
After you installed Ophelia and wrote some templates, how can you make it render web pages? Version 0.4 implements the Ophelia request handler as a WSGI application which can be used in any of the following ways (and more):
-
The application class
ophelia.wsgi.Application
can be used directly in Python code. -
The
ophelia
package comes with an executable script,ophelia-wsgiref
, which runs Ophelia inside a very simple HTTP server (wsgiref
from the Python standard library). This server can be used for trying out and developing things but is not suitable for production. -
The
ophelia
package includes an application factory which allows Ophelia to be configured into a WSGI stack using apaste.ini
-style configuration file.
The Ophelia documentation entails a small example project which has been installed and is explained at this site.
For a more technical description, see the project's documentation.