The Django PageView Application
March 2006 | Fredrik Lundh
This is a work in progress.
The pageview mini application is a fast and efficient dynamic front-end renderer, which can reformat HTML and XHTML pages from external sources on the fly. This can be useful when you want to:
- publish information from an existing content management system
- republish pages from an external source
- use a standard wiki to maintain the site, behind the scenes
- allow users to choose between different templates, depending on preferences or user agent.
- experiment with different styles, without having to generate multiple copies of an entire site.
The application uses tidy to clean up the source material as
needed, and
cElementTree
to pull out relevant XHTML fragments from it. Django’s
template
engine (dead link) is then used to render output pages,
and Django’s
caching
system (dead link) is used to cache rendered pages in memory (e.g. via
memcached).
The application maintains a page mapping database which controls
how URL are mapped to individual pages. You can use Django’s
administration interface (dead link) to remap or redirect pages. Since each page has an entry
in this database, you can add Django
comments
and other features to any or all pages on the site.
The application is based on the work done for the AltPyDotOrgCMS project (also see this sketch), where it was used to render pages from wiki source content.
Download
The code is currently only available via subversion:
$ svn co http://svn.effbot.org/public/pydotorg/page
For installation tips, see this article (dead link).
The current version is written for Django 0.91, and includes sample parsers for old-style www.python.org contents, latex-generated docs.python.org pages, effbot.org zone articles, pyref and pyfaq pages, and pages rendered in moinmoin‘s default style.
Examples #
You can find some
minimally styled (dead link) sample output here:
python-1 (dead link)
python-2 (dead link),
moinmoin-1 (dead link),
effbot-1 (dead link),
pyref-1 (dead link).
Here are some samples rendered with a python.org-style template:
“asyncore — Asynchronous socket handler (dead link)” (from the pyref project),
“Can’t find what you’re looking for? (dead link)“,
“Why Work on Python? (dead link)“, and
“PythonDoc (dead link)” (from effbot.org).
