durusmail: quixote-users: Generalizing form/widget API a bit
Generalizing form/widget API a bit
2003-11-25
2003-11-25
2003-11-25
2003-11-25
2003-11-25
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-26
2003-11-29
2003-11-30
2003-11-26
2003-11-26
2003-11-26
Patch: add html_attrs keyword arg to widget classes
2003-11-30
Patch: add html_attrs keyword arg to widget classes
2003-12-01
Patch: add html_attrs keyword arg to widget classes
2003-12-01
Patch: add html_attrs keyword arg to widget classes
2003-12-01
2003-12-02
2003-12-03
2003-12-02
Patch: add html_attrs keyword arg to widget classes
2003-12-01
Patch: add html_attrs keyword arg to widget classes
2003-12-01
Generalizing form/widget API a bit
Greg Ward
2003-11-26
On 25 November 2003, David Binger said:
> Agreed.  The set of xhtml attributes isn't huge, but there are some
> opportunities
> for confusion there: 'title' and 'id' come to mind, and what about
> 'xml:lang'?

Namespace confusion bad.  Syntactic sugar good.  Short keyword args
good.  Funky lowercase type names for web-specific stuff very handy
(witness htmltext).  How about (taking the caller's point of view):

  StringWidget("name", value="Greg",
               attrs=attrs(size=20, class_='myform'))

Note 'class_' instead of 'css_class' -- this is the convention used by
PyGTK to avoid collisions with keywords (builtins too? can't remember),
and it's as good as any.

Also note that 'attrs' could just be an alias for 'dict', since the dict()
builtin in Python 2.2 works as expected:

>>> dict(foo=34, bar=43)
{'foo': 34, 'bar': 43}

Cool.  (Yes, this would mean requiring Python 2.2, but nobody objected
to this idea when it was floated a few weeks ago...)

I think this can be done without messing with the htmltag() function,
which we really don't want to break at this point.  (Maaaaaybe break
'css_class' -- how long has that been in Quixote, anyways?  Anyone howl
at the idea of changing it to 'class_'?)

        Greg
--
Greg Ward                          http://www.gerg.ca/
I appoint you ambassador to Fantasy Island!!!

reply