web/formwidgets.py
changeset 4160 3fbdeef9a610
parent 4159 6b2b20c73d59
child 4163 b2747ed057e6
equal deleted inserted replaced
4159:6b2b20c73d59 4160:3fbdeef9a610
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
     9 
     9 
    10 from datetime import date
    10 from datetime import date
    11 from warnings import warn
    11 from warnings import warn
    12 
    12 
       
    13 from logilab.mtconverter import xml_escape
       
    14 from logilab.common.deprecation import deprecated
       
    15 
    13 from cubicweb import tags, uilib
    16 from cubicweb import tags, uilib
    14 from cubicweb.web import stdmsgs, INTERNAL_FIELD_VALUE, ProcessFormError
    17 from cubicweb.web import stdmsgs, INTERNAL_FIELD_VALUE, ProcessFormError
    15 
       
    16 from logilab.mtconverter import xml_escape
       
    17 
    18 
    18 class FieldWidget(object):
    19 class FieldWidget(object):
    19     """abstract widget class"""
    20     """abstract widget class"""
    20     # javascript / css files required by the widget
    21     # javascript / css files required by the widget
    21     needs_js = ()
    22     needs_js = ()
   123             if passwd1 is None:
   124             if passwd1 is None:
   124                 return None
   125                 return None
   125             return passwd1.encode('utf-8')
   126             return passwd1.encode('utf-8')
   126         raise ProcessFormError(form._cw._("password and confirmation don't match"))
   127         raise ProcessFormError(form._cw._("password and confirmation don't match"))
   127 
   128 
       
   129 
   128 class PasswordSingleInput(Input):
   130 class PasswordSingleInput(Input):
   129     """<input type='password'> without a confirmation field"""
   131     """<input type='password'> without a confirmation field"""
   130     type = 'password'
   132     type = 'password'
   131 
   133 
   132     def process_field_data(self, form, field):
   134     def process_field_data(self, form, field):
   133         value = super(PasswordSingleInput, self).process_field_data(form, field)
   135         value = super(PasswordSingleInput, self).process_field_data(form, field)
   134         if value is not None:
   136         if value is not None:
   135             return value.encode('utf-8')
   137             return value.encode('utf-8')
   136         return value
   138         return value
       
   139 
   137 
   140 
   138 class FileInput(Input):
   141 class FileInput(Input):
   139     """<input type='file'>"""
   142     """<input type='file'>"""
   140     type = 'file'
   143     type = 'file'
   141 
   144