web/formwidgets.py
changeset 10612 84468b90e9c1
parent 10522 1660a0fa4f43
child 10717 46f934bebd85
equal deleted inserted replaced
10611:f4dec0cca9a1 10612:84468b90e9c1
    96 __docformat__ = "restructuredtext en"
    96 __docformat__ = "restructuredtext en"
    97 
    97 
    98 from functools import reduce
    98 from functools import reduce
    99 from datetime import date
    99 from datetime import date
   100 from warnings import warn
   100 from warnings import warn
       
   101 
       
   102 from six import string_types
   101 
   103 
   102 from logilab.mtconverter import xml_escape
   104 from logilab.mtconverter import xml_escape
   103 from logilab.common.deprecation import deprecated
   105 from logilab.common.deprecation import deprecated
   104 from logilab.common.date import todatetime
   106 from logilab.common.date import todatetime
   105 
   107 
   280         understandable by the associated `field`. That value may be correctly
   282         understandable by the associated `field`. That value may be correctly
   281         typed or a string that the field may parse.
   283         typed or a string that the field may parse.
   282         """
   284         """
   283         posted = form._cw.form
   285         posted = form._cw.form
   284         val = posted.get(field.input_name(form, self.suffix))
   286         val = posted.get(field.input_name(form, self.suffix))
   285         if isinstance(val, basestring):
   287         if isinstance(val, string_types):
   286             val = val.strip()
   288             val = val.strip()
   287         return val
   289         return val
   288 
   290 
   289     # XXX deprecates
   291     # XXX deprecates
   290     def values_and_attributes(self, form, field):
   292     def values_and_attributes(self, form, field):
   991 
   993 
   992     def process_field_data(self, form, field):
   994     def process_field_data(self, form, field):
   993         req = form._cw
   995         req = form._cw
   994         values = {}
   996         values = {}
   995         path = req.form.get(field.input_name(form, 'path'))
   997         path = req.form.get(field.input_name(form, 'path'))
   996         if isinstance(path, basestring):
   998         if isinstance(path, string_types):
   997             path = path.strip()
   999             path = path.strip()
   998         if path is None:
  1000         if path is None:
   999             path = u''
  1001             path = u''
  1000         fqs = req.form.get(field.input_name(form, 'fqs'))
  1002         fqs = req.form.get(field.input_name(form, 'fqs'))
  1001         if isinstance(fqs, basestring):
  1003         if isinstance(fqs, string_types):
  1002             fqs = fqs.strip() or None
  1004             fqs = fqs.strip() or None
  1003             if fqs:
  1005             if fqs:
  1004                 for i, line in enumerate(fqs.split('\n')):
  1006                 for i, line in enumerate(fqs.split('\n')):
  1005                     line = line.strip()
  1007                     line = line.strip()
  1006                     if line:
  1008                     if line: