Ian Bicking: the old part of his blog

Re: Further FormEncode Work...

I really like how htmlfill works. I think it can function as neat templating system too! If we just learn it about new types of widgets, so it can fill them... Maybe using some kind of schema:

class TableWidget:
    class_ = 'grid' #maybe htmlfill can use css class to find element in the page?
    rows = RepeatWidget()
    paging = PagingWidget() 

IMHO even most fancy designed website can be split into standard widgets... Well, maybe I want it to be so :))

Comment on Further FormEncode Work...
by Ksenia

Comments:

I'm actually very reluctant to add something like this -- that's the kind of complexity that htmlfill is specifically meant to avoid, because I've gone down that path before and it didn't work well. But the form building you are thinking of could be implemented separately -- this is some of what formgen is meant to provide. You can't quite do this now, but something like this should be possible at some point:

from formgen import *
class CCField(FormTableLayout):
    layout = [['cc_name'], 
              ['cc_number', 'cc_type', 'cc_expiration', '=MM/YY']] 
        # That last item is a literal instruction
    cc_name = Text(size=40)
    cc_number = Text(size=16)
    cc_type = Select(selections=['Visa', 'Mastercard', 'AmEx'])
    cc_expiration = Text(size=5)

And then that would be a reusable "widget". But it just gets rendered to HTML, and htmlfill fills it in -- nothing more. Another subclass of Layout might even work with a template, but create the <input...> tags and whatnot.

# Ian Bicking