[formwidgets] move TextArea constants to the class level
This will make it easy to override them.
--- a/web/formwidgets.py Mon Jun 22 12:23:50 2015 +0200
+++ b/web/formwidgets.py Wed Jun 03 12:36:31 2015 +0200
@@ -400,6 +400,9 @@
class TextArea(FieldWidget):
"""Simple <textarea>, will return a unicode string."""
+ _minrows = 2
+ _maxrows = 15
+ _columns = 80
def _render(self, form, field, renderer):
values, attrs = self.values_and_attributes(form, field)
@@ -413,9 +416,9 @@
lines = value.splitlines()
linecount = len(lines)
for line in lines:
- linecount += len(line) / 80
- attrs.setdefault('cols', 80)
- attrs.setdefault('rows', min(15, linecount + 2))
+ linecount += len(line) / self._columns
+ attrs.setdefault('cols', self._columns)
+ attrs.setdefault('rows', min(self._maxrows, linecount + self._minrows))
return tags.textarea(value, name=field.input_name(form, self.suffix),
**attrs)