ANN: EmPy version 2.3 -- A templating system in Python
Erik Max Francis
max@alcyone.com
Thu, 20 Feb 2003 05:13:50 -0800
Summary
A templating system for Python.
Overview
EmPy is a system for embedding Python expressions and statements
in template text; it takes an EmPy source file, processes it, and
produces output. This is accomplished via expansions, which are
special signals to the EmPy system and are set off by a special
prefix (by default the at sign, '@'). EmPy can expand arbitrary
Python expressions and statements in this way, as well as a
variety of special forms. Textual data not explicitly delimited
in this way is sent unaffected to the output, allowing Python to
be used in effect as a markup language. Also supported are "hook"
callbacks, recording and playback via diversions, and dynamic,
chainable filters. The system is highly configurable via command
line options and embedded commands.
Expressions are embedded in text with the '@(...)' notation;
variations include conditional expressions with '@(...?...:...)'
and the ability to handle thrown exceptions with '@(...$...)'. As
a shortcut, simple variables and expressions can be abbreviated as
'@variable', '@object.attribute', '@function(arguments)',
'@sequence[index]', and combinations. Full-fledged statements
are embedded with '@{...}'. Forms of conditional, repeated, and
recallable expansion are available via '@[...]'. A '@' followed
by a whitespace character (including a newline) expands to
nothing, allowing string concatenations and line continuations.
Comments are indicated with '@#' and consume the rest of the line,
up to and including the trailing newline. '@%' indicate
"significators," which are special forms of variable assignment
intended to specify per-file identification information in a
format which is easy to parse externally. Escape sequences
analogous to those in C can be specified with '@\...', and finally
a '@@' sequence expands to a single literal at sign.
Getting the software
The current version of empy is 2.3.
The latest version of the software is available in a tarball here:
http://www.alcyone.com/pyos/empy/empy-latest.tar.gz.
The official URL for this Web site is
http://www.alcyone.com/pyos/empy/.
Requirements
EmPy should work with any version of Python from 1.5.x onward. It
has been tested with all major versions of CPython from 1.5 up,
and Jython from 2.0 up. The included test script is intended to
run on UNIX-like systems with a Bourne shell.
License
This code is released under the GPL.
Mailing lists
There are two EmPy related mailing lists available. The first is
a receive-only, very low volume list for important announcements
(including releases). To subscribe, send an email to
mailto:empy-announce-list-subscribe@alcyone.com.
The second is a general discussion list for topics related to
EmPy, and is open for everyone to contribute; announcements
related to EmPy will also be made on this list. The author of
EmPy (and any future developers) will also be on the list, so it
can be used not only to discuss EmPy features with other users,
but also to ask questions of the author(s). To subscribe, send an
email to mailto:empy-list-subscribe@alcyone.com.
...
Release history [since 2.2]
- 2.3; 2003 Feb 20. Proper and full support for concurrent and
recursive interpreters; protection from closing the true stdout
file object; detect edge cases of interpreter globals or
'sys.stdout' proxy collisions; add globals manipulation
functions 'empy.getGlobals', 'empy.setGlobals', and
'empy.updateGlobals' which properly preserve the 'empy'
pseudomodule; separate usage info out into easily accessible
lists for easier presentation; have -h option show simple usage
and -H show extened usage; add 'NullFile' utility class.
- 2.2.6; 2003 Jan 30. Fix a bug in the 'Filter.detach' method
(which would not normally be called anyway).
- 2.2.5; 2003 Jan 9. Strip carriage returns out of executed code
blocks for DOS/Windows compatibility.
- 2.2.4; 2002 Dec 23. Abstract Filter interface to use methods
only; add @[noop: ...] substitution for completeness and block
commenting.
- 2.2.3; 2002 Dec 16. Support compatibility with Jython by
working around a minor difference between CPython and Jython in
string splitting.
- 2.2.2; 2002 Dec 14. Include better docstrings for pseudomodule
functions; segue to a dictionary-based options system for
interpreters; add 'empy.clearAllHooks' and 'empy.clearGlobals';
include a short documentation section on embedding interpreters;
fix a bug in significator regular expression.
- 2.2.1; 2002 Nov 30. Tweak test script to avoid writing
unnecessary temporary file; add 'Interpreter.single' method;
expose 'evaluate', 'execute', 'substitute', and 'single' methods
to the pseudomodule; add (rather obvious) 'EMPY_OPTIONS'
environment variable support; add 'empy.enableHooks' and
'empy.disableHooks'; include optimization to transparently
disable hooks until they are actually used.
--
Erik Max Francis / max@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ It's better to be quotable than to be honest.
\__/ Tom Stoppard
Crank Dot Net / http://www.crank.net/
Cranks, crackpots, kooks, & loons on the Net.