Hello, webware-devel,
My name is Donovan Preston. I have been lurking on the list for a while
and have posted occasionally, but I feel now a formal introduction is
required. A few months ago I got a job at InterSight working for Paul
McGavin, whom some of you may know since he spent quite a bit of time at
the end of 2000 and beginning of 2001 meeting the Python community and
weighing the options for web development (Java vs. Python at first, then
Zope vs. WebWare for Python).
Anyway, we settled on WebWare to do an image handling front end for one
of our existing projects, and I quickly was able to get up to speed with
using WebWare and enjoyed developing hierarchies of Page subclasses to
do what I needed to do.
However, I work with a designer who uses Dreamweaver, and I could see no
clear and clean seperation of presentation from logic. At the time, ZPT
(Zope Page Templates) had just been released, and while there was some
discussion of Templates on webware-devel, none of the approaches were to
my liking. So I took it upon myself to see if I could get the TAL (Tag
Attribute Language) component of ZPT working with WebKit, and it was
surprisingly easy.
Here are the instructions:
- Download TAL from
http://www.zope.org/Members/4am/ZPT/TAL-1.2.1.tar.gz/view
- Untar and put in your site-packages, or somewhere else on your path.
- Create a .path file inside of the TAL directory which points to your
python libraries directory. In the readme they tell you to point this to
your Zope lib/python, but it works fine for me if I point it at
/usr/local/lib/python2.1/
- Save the attached TALPage.py somewhere on your python path.
- Create a new page and inherit from TALPage. Override self.base and
self.file so that, when concatenated together, they point to a TAL HTML
file somewhere on your hard disk you wish to process.
- You can access methods or data members of this page from your TAL like
this:
<p tal:content="python:page.getContent()">Dummydata</p>
Where getContent is a function on your page object.
That's it! While the TAL syntax is slightly unwieldy, I think it gets
some fundamental things right, and developing with it has been a
complete joy. It is a real time-saver to be able to edit the template
page in Dreamweaver or GoLive and not have to worry about either editor
messing up the template instructions. Even when our graphic designer cut
and pastes a table from one document to another, the template commands
are preserved and the logic continues to work properly! I urge anyone
interested in these ongoing template discussions to try it.
TALPage.py
TALPage.py