Changeset 6277


Ignore:
Timestamp:
4 Jun 2011, 11:19:25 (13 years ago)
Author:
uli
Message:

Update convert interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py

    r6276 r6277  
    377377    """
    378378
    379     def applyRowData(data_dict, context, form_fields=None):
    380         """Apply data in `data_dict` to `context`.
    381 
    382         `data_dict` is a dict containing field names as
    383         keys. `context` is an object or string.
    384 
    385         `data_dict` gives the values to set on an object where the
    386         dict contains the attribute names as keys and values to set as
    387         values. Values and keys have to be strings.
    388 
    389         If `context` is a string, this is understood as a factory name
    390         and we will try to create a proper object calling
    391         ``createObject()``. If it is an object then we will update
    392         this object.
    393 
    394         `form_fields` are by default (``None``) buildt from the given
    395         `iface` but can also be passed in to override the
    396         default. This might be handy if you want to omit or select
    397         certains fields from the interface.
    398 
    399         Returns a tuple ``(<ERROR_LIST, INV_ERR_LIST, OBJ>)`` where
    400         ``ERROR_DICT`` is a dict of errors for single fields (if
    401         happened), ``INV_ERR_LIST`` is a list of invariant errors
    402         happened (errors that apply to several fields), and ``OBJ`` is
    403         the created/updated object.
    404         """
     379    def fromStringDict(self, data_dict, context, form_fields=None):
     380        """Convert values in `data_dict`.
     381
     382        Converts data in `data_dict` into real values based on
     383        `context` and `form_fields`.
     384
     385        `data_dict` is a mapping (dict) from field names to values
     386        represented as strings.
     387
     388        The fields (keys) to convert can be given in optional
     389        `form_fields`. If given, form_fields should be an instance of
     390        :class:`zope.formlib.form.Fields`. Suitable instances are for
     391        example created by :class:`grok.AutoFields`.
     392
     393        If no `form_fields` are given, a default is computed from the
     394        associated interface.
     395
     396        The `context` can be an existing object (implementing the
     397        associated interface) or a factory name. If it is a string, we
     398        try to create an object using
     399        :func:`zope.component.createObject`.
     400
     401        Returns a tuple ``(<FIELD_ERRORS>, <INVARIANT_ERRORS>,
     402        <DATA_DICT>)`` where
     403
     404        ``<FIELD_ERRORS>``
     405           is a list of tuples ``(<FIELD_NAME>, <ERROR>)`` for each
     406           error that happened when validating the input data in
     407           `data_dict`
     408
     409        ``<INVARIANT_ERRORS>``
     410           is a list of invariant errors concerning several fields
     411
     412        ``<DATA_DICT>``
     413           is a dict with the values from input dict converted.
     414
     415        If errors happen, i.e. the error lists are not empty, always
     416        an empty ``<DATA_DICT>`` is returned.
     417
     418        If ``<DATA_DICT>` is non-empty, there were no errors.
     419        """
Note: See TracChangeset for help on using the changeset viewer.