zope.formlib - Overriding default widget attributes

Alex Leach <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <1526757.1jdgtd4Nh3@metabuntu>
Dear Zope Devs,

I'm trying to remove a couple of default attributes from the rendered version 
of the schema.Text widget, namely cols and rows.

I tried overriding the widgets attributes with None, which didn't work. I then 
found in renderTag, in zope.formlib-4.0.6-py2.7.egg/zope/formlib/widget.py:603 
that if a value of one of the keyword arguments (**kw) is set to None, then 
the value is set to the key, and a deprecation warning is issued. In my case, 
this therefore produces HTML with attributes like cols="cols", and 
rows="rows". I don't like that at all, as all my styles are defined in CSS and 
jQuery, and this overrides them!

So, please can this be replaced with a `continue` flow statement instead??

Suggested patch:-

zope.formlib-4.0.6-py2.7.egg/formlib> diff widget.py widget.py.orig 
600c600,602
<         for key, value in sorted(kw.items()):
---
>         items = kw.items()
>         items.sort()
>         for key, value in items:
602c604,611
<                 continue
---
>                 warnings.warn(
>                     "None was passed for attribute %r.  Passing None "
>                     "as attribute values to renderTag is deprecated. "
>                     "Passing None as an attribute value will be disallowed "
>                     "starting in Zope 3.3."
>                     % key,
>                     DeprecationWarning, stacklevel=2)
>                 value = key

In fact, I'd also get rid of the `if kw:` line, as it seems unnecessary...

Cheers,
Alex

ps. Sorry if this is a duplicate. I think my original message got rejected as 
I hadn't subscribed...

-- 
Alex Leach
Department of Biology
University of York
York YO10 5DD
United Kingdom
www: http://bioltfws1.york.ac.uk/~albl500
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm
-- 
Alex Leach BSc. MRes.
Department of Biology
University of York
York YO10 5DD
United Kingdom
www: http://bioltfws1.york.ac.uk/~albl500
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.