20 Apr 2006 lkcl   » (Master)

well, i haven't had much that i can write about, because i've been working. but i recently had some time available to start a project, and i started out with zope (which is what i am developing with at work) and within three days made a decision to abandon zope and use mod_python instead.

conversion - of the 1500 lines of python+templates i'd written up until then - was very simple and very quick, by virtue of having stuck to some guidelines:

1) for god's sake don't use anything in dtml except dtml-if (which should be a true-false test only), dtml-else, dtml-var (which should be simple variables only) and dtml-in.

DO NOT, under ANY CIRCUMSTANCES, use dtml-call or any kind of complex mapping.

2) anything complex is done by a python function, which _explicitly_ calls a variable (an instance of an HTMLFile) manually passing in the REQUEST dictionary and some additional keywords via **kwargs or named parameters:

    contents of index_html_file.dtml:
< html >
< title > <dtml-var "title">
< body > stuff < / body >
< / html >

def index_html(self, REQUEST): """ comment to keep zope happy """

return self.index_dtml_file(self, REQUEST, title='Hello')

by following these simple rules, i was able to install python-htmltmpl, and quite literally do a global search/replace on dtml-in with TMPL_LOOP, dtml-var with TMPL_VAR - you get the idea.

i've since investigated SQLObject/SQLBuilder, formencode, mod_python and htmltmpl, and ... i can't imagine ever doing, by choice, web programming with anything else.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!