Пример #1
0
    def __init__(self,
                 label=u(''),
                 validators=None,
                 filters=tuple(),
                 description=u(''),
                 id=None,
                 default=None,
                 widget=None,
                 _form=None,
                 _name=None,
                 _translations=None):
        """
        Construct a new field.

        :param label:
            The label of the field. Available after construction through the
            `label` property.
        :param validators:
            A sequence of validators to call when `validate` is called.
        :param filters:
            A sequence of filters which are run on input data by `process`.
        :param description:
            A description for the field, typically used for help text.
        :param id:
            An id to use for the field. A reasonable default is set by the form,
            and you shouldn't need to set this manually.
        :param default:
            The default value to assign to the field, if no form or object
            input is provided. May be a callable.
        :param _form:
            The form holding this field. It is passed by the form itself during
            construction. You should never pass this value yourself.
        :param _name:
            The name of this field, passed by the enclosing form during its
            construction. You should never pass this value yourself.

        If `_form` and `_name` isn't provided, an :class:`UnboundField` will be
        returned instead. Call its :func:`bind` method with a form instance and
        a name to construct the field.
        """
        self.name = _name
        self.label = label
        if _translations is not None:
            self._translations = _translations
        self.id = id or self.name
        if validators is None:
            validators = []
        self.validators = validators
        self.filters = filters
        if widget is not None:
            self.widget = widget
        self.description = description
        self.type = type(self).__name__
        self.default = default
        self.raw_data = None
Пример #2
0
    def __init__(self, label=u(''), validators=None, filters=tuple(),
                 description=u(''), id=None, default=None, widget=None, 
                 _form=None, _name=None, _translations=None):
        """
        Construct a new field.

        :param label:
            The label of the field. Available after construction through the
            `label` property.
        :param validators:
            A sequence of validators to call when `validate` is called.
        :param filters:
            A sequence of filters which are run on input data by `process`.
        :param description:
            A description for the field, typically used for help text.
        :param id:
            An id to use for the field. A reasonable default is set by the form,
            and you shouldn't need to set this manually.
        :param default:
            The default value to assign to the field, if no form or object
            input is provided. May be a callable.
        :param _form:
            The form holding this field. It is passed by the form itself during
            construction. You should never pass this value yourself.
        :param _name:
            The name of this field, passed by the enclosing form during its
            construction. You should never pass this value yourself.

        If `_form` and `_name` isn't provided, an :class:`UnboundField` will be
        returned instead. Call its :func:`bind` method with a form instance and
        a name to construct the field.
        """
        self.name = _name
        self.label = label
        if _translations is not None:
            self._translations = _translations
        self.id = id or self.name
        if validators is None:
            validators = []
        self.validators = validators
        self.filters = filters
        if widget is not None:
            self.widget = widget
        self.description = description
        self.type = type(self).__name__
        self.default = default
        self.raw_data = None
Пример #3
0
 def _value(self):
     return self.data is not None or u('')
Пример #4
0
 def _value(self):
     return self.data is not None and unicode(self.data) or u('')
Пример #5
0
 def process_formdata(self, valuelist):
     if valuelist:
         self.data = valuelist
     else:
         self.data = u('')
Пример #6
0
 def _value(self):
     return self.data is not None or u('')
Пример #7
0
 def _value(self):
     return self.data is not None and unicode(self.data) or u('')
Пример #8
0
 def process_formdata(self, valuelist):
     if valuelist:
         self.data = valuelist
     else:
         self.data = u('')