HTML form pre-populating functionality or hints on building my own

Evan Simpson evan at 4-am.com
Thu Apr 17 18:38:17 CEST 2003


Scott Chapman wrote:
> I'm wanting to find (or make) a module that will take a HTML file, locate the 
> input-related form tags (<INPUT, <TEXTAREA, <SELECT, <OPTION) and modify them 
> by putting in values from a dictionary (i.e. pre-populate the form). I want a 
> module that is implemented 100% in python and does _not_ use any special tags 
> to do this (such as webware, albatross, spyce, etc.)

This won't be of any immediate use to you (I haven't got working code 
yet), but I'm building a system called TERSE which will do what you 
want.  It's intended to be an enhancement to Zope Page Templates, 
allowing you to completely remove code from templates.

TERSE stands for TEmplate Rule Set Engine, where Rule Sets are lists of 
element-matching patterns and associated declarative logic.  Your 
application of it might look a bit like this:

@document {
     data = options/data;
}
textarea[name] {
     name = attrs/name;
     content: path(data/?name | nothing);
}
input[name][type='text'],
   input[name][type='password'],
   input[name]:not([type]) {
     name = attrs/name;
     [value] = path(data/?name | nothing);
}
select[name] {
     name = attrs/name;
     selected = path(data/?name | nothing);
}
select[name] option[value] {
     value = attrs/value;
     @if(value==selected) { [selected] = 'selected'; }
}

Cheers,

Evan @ 4-am







More information about the Python-list mailing list