Hi Winston.
I'm one of the authors of FormKit.
We specifically did not have a recipe syntax for the construction of a form, preferring instead for FormKit to be standard "pythonic". We never found any of these "short-cut syntaxes" ever really shortened anything, and it was always hard to remember how to do it. Straight-forward python, while perhaps more typing than some kind of encoded python expression, always seemed easier for us to remember, and of course easier to teach.
I understand your goal, and agree that the way forms are built in the examples are a little verbose. That of course was to help in the tutorial process of learning FormKit. I don't find that your proposal is any more clear, but perhaps to your mind it is; we all think slightly differently, I suppose.
The nesting of class instantiation would also make it pretty difficult to debug, since all of that happens in what is basically one big expression.
In the real world, we're usually setting choices in a loop from a database, and things like that; this is when the flexibility of one-by-one expressions really comes into play. It would be hard to do that in your syntax without a list comprehension expression or something.
Of course, you are free to try it out and see what you get. It would be a small change to get the constructor to accept the add argument. I'd be curious to see how it works out for you. You may also look at FunFormKit, which has a more config-file like syntax for making a new form.
Also consider just making the fields and sticking them in the form, rather than creating them inside of the addField()... like this (it may be clearer to your eye):
# make choices in a loop or from a database view or some such... survey = CheckboxSet('survey', label="Check all that apply") survey.setChoices( choices )
text = Fields.TextField('textBox',[notEmpty])
button = Fields.WebKitSubmitButton(name="osBtn",label="Make it So")
# stick all of those new fields into the form f.addField( survey ) f.addField( text ) f.addField( button )
Winston WOLFF wrote:
I hope this is the right list to discuss dAlchemy's FormKit. It's not included in WebWare, but I'm guessing many WebWare folks use it, and it doesn't have its own list.
[snip]
Here each constructor includes as the last element, an optional 'add' parameter. In it, you can pass a tuple of sub-elements that are added to the form. In this way I want to eliminate a lot of the wordiness of the all the addXxx() methods, and try to let the structure of my form show through. The indentation shows the structure, and the first word of each line shows what element is there.
Does anybody have any comments or suggestions before I try this out?
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ Webware-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-devel