Hippos Technical Systems BV - Larry Myerscough
These pages contain information about my family, my company, my hobbies and myself.
'Phileas' - Python-HTML integration - Larry's Elegant Alternative Solution
Phileas is a method of smoothly integrating html code within python
code without having to resort to templating (which I find leads to
unnatural and ugly code). It is by no means the first such venture
in this direction; indeeed it is inspired by a number of earlier
products with a similar aim. The features which distinguish phileas
from other such products are:
All HTML start-tags and end-tags are represented by python expressions;
For example, 'h.p | "this little sentence."' contructs an HTML paragraph.
Where parameters are required with the HTML start-tag, these are simply
specified in parentheses, e.g. 'h.a(href="some_url") | "link text"'.
The 'h' decribed in the previous item is a 'singleton' instance of
the class '_HTML40', defined within module 'phileas.py'. Many clases
corresponding to html tags are defined as classes within the scope
of HTML40. This class also possesses a member function '__str__'.
This ensures that the html tags are properly printed. It also
ensures that any nested sequences within the 'children' of the tag
are unwound to a single list.
The operator '|' (binary or) is used to associate child items with a tag.
These child items may be either strings or other html tags, possibly with
child items of their own. [The decision to use '|' rather then '+'
was not taken lightly but is nonetheless questionable: the author finds
it easy to associate the notion of 'binary or' with 'taking something
on board at the appropriate place', than is the case with '+'.
Use of phileas in web pages
This is no longer regarded as part of the phileas package as
Various styles of page are represented by class inheritance from a
generic 'Page' class defined in 'Page.py'. Pages of similar layout
within a single web-site design are represented by a common
sub-class of Page, e.g. 'MyPage' or 'CustomPage'. A further level of
sub-classing defines page layout for e.g displaying a single photo,
dislaying a collection of miniature photos, displaying a blog
directory or a blog entry etc.
Facilities to auto-generate photo-indices and individual python files
corresponding to uploaded photos exist.
Releases 0.2 and 0.3 were advertised on python-forum a year or two
ago. I kept quiet about intermediate releases, largely because I kept
changing my mind about the best approach to some issues.
Release 0.8 is now ready for exposure to a wider world.
You may view/capture the python source of any page on this site by
navigating to that page, then selecting 'show source' from the left
The source of the following low-level support files can be viewed by clicking the filename below:
You may download the source of the above deliverables in this zip file
|This Panel on the Right is used for local navigation
- not yet fully implemented as you can see!