durusmail: quixote-users: Quixote and non-programmers (was Re: Relational database access in Quixote applicatoins)
Relational database access in Quixote applicatoins
2003-01-10
Relational database access in Quixote applicatoins
2003-01-10
2003-01-10
2003-01-13
2003-01-13
Quixote and non-programmers (was Re: Relational database access in Quixote applicatoins)
2003-01-13
2003-01-13
2003-01-13
2003-01-13
2003-01-13
Quixote and non-programmers (was Re: Relational database access in Quixote applicatoins)
Matt Campbell
2003-01-13
I know you guys tend not to like HTML template languages, but lately
I've found one that has really impressed me.  It's the wt (web template)
language from jonpy (http://jonpy.sourceforge.net/), which is Yet Another
web application framework for Python.

wt is a very simple but powerful template language which is implemented
in jonpy in about 5K of Python code.  It does not embed Python, or any
programming language for that matter, inside HTML.  Instead, it introduces
two new constructs:  placeholders and sectoins.  To give you an idea of
how it works, here's a wt template for a Web page that lists open bugs
in a bug tracking system, in a file called "bugs.html":




View Open Bugs


View Open Bugs

ID Reporter Assigned To Summary
$$id$$ $$reporter$$ $$assigned_to$$ $$summary$$
This template alone is not enough; an accompanying Python class must also be written. One possible implementatoin of this class, in a file called "bugs.html.py", is as follows (for simplicity, the bugs are hard-coded, but they could also be retrieved from a database): class main(wt.TemplateCode): bugs = [(1234, "joe", "bob", "Bug 1"), (5678, "john", "bob", "Bug 2")] class bug(wt.TemplateCode): def main(self, template): for bug in self.outer.bugs: self.id, self.reporter, self.assigned_to, self.summary = bug self.process(template) So the main() method in the class corresponding to the "bug" section outputs the sub-template for that section once for each bug. The placeholders here are "id", "reporter", "assigned_to", and "summary". What I really like about wt is that the top-level template is a complete, valid HTML document. It can therefore be created and manipulated with WYSIWYG tools like Mozilla Composer, Dreamweaver, or MS FrontPage, though the comments that mark sections will probably need to be inserted by hand. HTML preprocessors like WML and htmlpp can also be used, as well as HTML syntax checkers like HTML Tidy (http://tidy.sourceforge.net/) and the W3C HTML validatoin service (http://validator.w3.org/). So the programmer could create a very simple template like the one given above and write the accompaying class, then let the Web designer design a more complicated template. As long as the designer puts the placeholders and section markers in the right place, the template and the class can be maintained by separate people. Of course, this is a very brief overview, and I've left out some important details. You can read more about wt at and see some more examples at . On Mon, Jan 13, 2003 at 08:41:11AM -0800, Titus Brown wrote: > Now that you ask, though, one way to make it at least a bit more friendly > would be to set up something that lets template functions be edited with > something like Dreamweaver or Mozilla Composer, I think. How difficult > would it be to write a wrapper that translates templates to/from something > that Dreamweaver can handle? -- Matt Campbell Phone: (316) 652-8727 WWW: http://pobox.com/~mattcampbell/
reply