On Sunday 30 November 2003 19:50, Skip Montanaro wrote:
> How about you allow both keyword args and an explicit attribute dict? That
> way, for the oddball stuff which clashes with Python syntax you go the
> extra step and use the dictionary, but for normal usage, keyword args do
> just fine:
>
> htmltag('input', type='text', size=20, maxlength=40)
> htmltag('textarea', rows=30, cols=80)
> htmltag('body', bgcolor='#fff', attrs={'class': 'mainpage'})
>
I miss something or may be i haven't understood nothing.
Have you tested all this stuff with the last html.py patch proposed?
I think all of these examples are already supported.
> Most of the time you won't need the attrs argument, but when you do
> encounter a recalcitrant attribute name, you won't have to remember how to
> sneak it by the Python parser. Of course, purists are free to just use
> attrs:
>
> htmltag('input', attrs={'type': 'text', 'size': 20, 'maxlength': 40})
> htmltag('textarea', attrs={'rows': 30, 'cols': 80})
> htmltag('body', attrs={'bgcolor': '#fff', 'class': 'mainpage'})
>
Maybe you are talking about widget instead of htmltag. Then,
as a old algebra teacher liked to say:
Aren't you merging potatoes with tomatoes?
Greg Ward said:
>OK, the "Generalizing frame/widget framework a bit" thread had lots of
>good things to say. I'm attaching a patch in two parts that, IMHO,
>represents the group consensus. This is relative to Quixote 0.7a2; my
>previous patch in this direction is withdrawn.
I'm really happy with the resolution of this thread is taking.
I'm going to test it.
Thank you for your comprehension.
Greg> because those constructor keyword args are just darn convenient.
I think this is a widget constructor decission. In this case, yours.
htmltag doc says:
Note that keyword args are transformed into tag attributes in hash
order (ie. unpredictable and subject to change across Python
versions).
I have already thought on this. Several unclear solutions appear to me:
A sort function inside htmlattrs (awkful?), subclassing dict for
htmlattrs(expensive?). As a secondary matter, i wouldn't like to begin a
subthread on this now.
Oscar Rambla
CODI