[Zope-dev] zope.formlib - Overriding default widget attributes

Alex Leach albl500 at york.ac.uk
Thu Apr 12 17:48:44 UTC 2012


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


More information about the Zope-Dev mailing list