On 2/7/06, Michele Cella <[EMAIL PROTECTED]> wrote: > As a guideline I used the w3school and added to the constructor only > the required attributes, so we have cols and rows for a textarea: > > http://www.w3schools.com/tags/tag_textarea.asp
I'd actually go farther than that. I think the constructor should include the "most commonly used" attributes. This will prove helpful for documentation and is easier for widget users (they'll have to resort to attrs less). > Regarding this I think we should really write some guidelines for our > Widgets to follow and to keep consistency, something like "Zen of TG > Widgets":D. > > For example: > > 1) Keep the programming logic out of templates > 2) Use template_vars for trivial case > 3) If you need new parameters in the constructor always add name as the > first, then your parameters, then **kw and call the super constructor > with (name, **kw) > 4) If you are overriding a method remember to always call the super > method before doing anything (since we want to change it's behavior we > should act after it not before) > 5) If your widget is simple use the SimpleWidget as a base class > 6) If you need to support HTML attributes support only the required one > in the constructor (reference w3schools.org) and the optionals by using > attrs > ... > > Regarding point number 4) if we agree on this (or the other option of > reporting the entire base class signature) we should update the actual > code. > If 4) is Kevin choice we should revert what Alberto has done (ops, > sorry Alberto :D), probably 4) is better if followed by any one since > it's not such a pain as reporting the entire signature, is less error > prone and does not break with every API change in the widget base class > (I'm already hearing Alberto screaming). These seem like a good start to guidelines (except #6, which I talked about above). As for #4, I think we can be more explicit that than in suggestions about overrides. It'd be nice to document how people should override __init__, display and update_data which are really the main things that people will need to override. Kevin

