KBD

Keith Devens .com

Thursday, March 18, 2010 Flag waving
That which yields, is not always weak. – Jacqueline Carey (Kushiel's Dart)

Archive: November 23, 2003

← November 22, 2003November 24, 2003 →

Daily link icon Sunday, November 23, 2003

Perl Slurp-Eaze

Perl.com: Perl Slurp-Eaze

FunFormKit

The nice thing about working with Python is that it seems there's so much code out there that's similar to how I would have written the code. FunFormKit is similar to my form/action library. After a quick glance at the site, I think I like how I structured mine a little better, but if I can use their code and avoid having to rewrite my own I'm all for it. What's nice is that their code is more complete than mine ever was.

In case you're interested, the way I structured mine was as follows: FunFormKit is set up in terms of the HTML elements that will be printed. I split the structure of it into two separate components... "actions" which handle the logical structure of the form, how to validate it, and how to process the result, and a "form helper" which took that logical structure and printed it as an HTML form. You could give hints to the helper about how you wanted a certain field printed, and if you didn't give it any hints it would try to choose a sensible default.

To give an example of what I'm talking about, a set of radio buttons, a single-select list box, and a drop-down box all have the same data model, as do a set of checkboxes and a multi-select list box. Similarly for text fields and and text areas. So, for the radio buttons example, you could specify a list of options and indicate that only one was required, and then you could print it any way you chose using the form helper. The form helper even had nice convenience functions for printing a whole bunch of checkboxes or radio buttons in rows and columns.

This separation was nice and logical, and it was really nice to be able to specify actions with no concern for how they would be laid out on an HTML form. But in practice, the scheme FunFormKit uses is probably plenty good enough. We'll see.

Update: Note that in addition to the "hints" you could give to the form helper, you could use it to print fields directly and have full control. If I do write my own, I'll probably try to provide some code meant to be used with Cheetah that'll make it easier to print form fields in a template.

← November 22, 2003November 24, 2003 →
March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

new⇒I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.06s.

(Used 7 db queries)