Standards Support
The program is divided into loosely coupled modules using standard
interfaces wherever possible, allowing replacement of different
components with commercial or open-source alternatives. This is
particularly true of the RSS weblog support, where the standards
are fairly mature and there are many different levels on which
to mix and match components.
RSS 2.0. The RSS content plug-in translates weblogs
(in RSS newsfeed format) into HTML. The RSS source file can come
from your machine or from a URL on a remote server. Adjustable
parameters are limits on the number of items and the start index,
date range, and category, as well as different templates. This
allows multiple-column layouts, layouts that show the most recent
items in full and older items in title-only form, and multiple
views of the same data. DirectRSS (included) gives weblog
posting applications access to read and modify local RSS files
through the MetaWeblog, b2, and Blogger APIs.
blogBrowser RSS. By specifying a folder
instead of a file as the RSS target, both the RSS content plug-in
and DirectRSS support all their operations on Dave Winer's blogBrowser
format. So a folderful of monthly RSS archives will act just like
one big RSS file as far as weblog posting applications are
concerned. New monthly RSS files are created automatically
when needed.
HTML. The template engine contains a full HTML
4.0 parser with XHTML extensions, designed to pass ASP, PHP, JSP,
and other server-side code through unchanged. All source code
formatting is preserved. The Include content
plug-in inserts the body of an HTML document inside another. This
eliminates the need to use files containing only HTML fragments,
while still outputting well-formed HTML.
XML-RPC: The DirectRSS module, which stands
alone from the rest of the program, implements the XML-RPC MetaWeblog
API, Blogger API, and b2 API interfaces. Instead of operating
on a database, the module works directly on RSS files, allowing standard
weblogging tools on the desktop to update them.
CGI: The web-based administration tool can run
as a CGI module from Apache and Microsoft IIS, for deployment
on existing web servers. This tends to be most useful for running
the system directly on hosted servers. Security is provided through
the web server's built-in password controls.
HTTP: For situations where the plain CGI implementation
is difficult to configure, a built-in HTTP web server fills the
gap. This tends to be most useful for personal machines, which
either don't have a built-in web server or don't give CGI programs
sufficient privileges by default to modify files within the web
root. This is typically the case for local installations of Apache
without suexec preinstalled, as in Mac OS X. For security, access
is restricted to the local host.
Command line: The template engine has a command-line
interface, allowing updates to be triggered from shell scripts,
batch files, and scheduled tasks (Windows) or cron jobs (Unix).
Content Plug-ins: activated by a tag in the
content page or template. They output HTML code, usually by processing
external data specified by parameters. Includes, navigation, and
RSS input are implemented as plug-ins. The Python interface to
plug-in modules is very small and well-defined, so it's easy to
write another. Dropping them into the program folder is enough
to install them. Source code for a minimal content plug-in, named
Helloworld_plugin.py:
class Helloworld:
def __init__(self, pathTranslator):
# The pathTranslator is a utility object that translates between
# virtual paths on the Web server and physical paths on the hard disk.
# This simple class doesn't need to use it.
self.pathTranslator = pathTranslator
def write(self, out, paramsText, documentInfo):
out.write("Hello world!")
return 1
# Return a true value (1) to indicate that we want to override
# the content that was there before.
When applying templates, <div id="template_helloworld"></div>
in an HTML page will be replaced with <div id="template_helloworld">Hello
world!</div>. Subsequent applications will leave
the text unchanged. Plug-in names are not case-sensitive, but
since Python itself is, module filenames must follow the title-case
convention with the first letter capitalized and _plugin
appended to the end.