Ignore:
Timestamp:
4 Jun 2011, 02:29:21 (13 years ago)
Author:
uli
Message:

Finally make the new converter work. API-wise it is as good as the old one (can import everyting, the old one could),
but design-wise it might be much more powerfull. Basically it can handle/convert all content-types for which one can
create an Add- or EditForm? successfully. In other words: if you manage to write an edit form for some content type,
then you can also create an importer for that content-type. Still finetuning needed (for dates, bool data, etc.) but
the main things work.

File:
1 edited

Legend:

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

    r6226 r6273  
    378378        """Unregister any plugins not wanted to be in the PAU.
    379379        """
     380
     381class IObjectConverter(Interface):
     382    """Object converters are available as simple adapters, adapting
     383       interfaces (not regular instances).
     384
     385    """
     386
     387    def applyRowData(data_dict, context, form_fields=None):
     388        """Apply data in `data_dict` to `context`.
     389
     390        `data_dict` is a dict containing field names as
     391        keys. `context` is an object or string.
     392
     393        `data_dict` gives the values to set on an object where the
     394        dict contains the attribute names as keys and values to set as
     395        values. Values and keys have to be strings.
     396
     397        If `context` is a string, this is understood as a factory name
     398        and we will try to create a proper object calling
     399        ``createObject()``. If it is an object then we will update
     400        this object.
     401
     402        `form_fields` are by default (``None``) buildt from the given
     403        `iface` but can also be passed in to override the
     404        default. This might be handy if you want to omit or select
     405        certains fields from the interface.
     406
     407        Returns a tuple ``(<ERROR_LIST, INV_ERR_LIST, OBJ>)`` where
     408        ``ERROR_DICT`` is a dict of errors for single fields (if
     409        happened), ``INV_ERR_LIST`` is a list of invariant errors
     410        happened (errors that apply to several fields), and ``OBJ`` is
     411        the created/updated object.
     412        """
Note: See TracChangeset for help on using the changeset viewer.