Default info massage to appropiate format/style.

        This processing is called on preprocess and postprocess, AKA
        before and after conversion of fields to appropiate
        format/style.

        Perfect example: custom fields on certain objects is a mess
        (IMHO) when retrieved from Mambu, so some easiness is
        implemented here to access them. See some of this objects
        modules and pydocs for further info.

        Tasks done here:

        - Each custom field is given a 'name' key that holds the field
          name, and for each keyed name, the value of the custom field is
          assigned. Each pair of custom field name/value is entered as a
          new property on the main dictionary, allowing an easy access to
          them, not nested inside a pretty dark 'customInformation/Values'
          list.

        - Every item on the attrs dictionary gets stripped from trailing
          spaces (useful when users make typos).

        PLEASE REMEMBER! whenever you call postprocess on inherited
        classes you should call this method too, or else you lose the
        effect of the tasks done here.

def _process_fields(self):
        """Default info massage to appropiate format/style.

        This processing is called on preprocess and postprocess, AKA
        before and after conversion of fields to appropiate
        format/style.

        Perfect example: custom fields on certain objects is a mess
        (IMHO) when retrieved from Mambu, so some easiness is
        implemented here to access them. See some of this objects
        modules and pydocs for further info.

        Tasks done here:

        - Each custom field is given a 'name' key that holds the field
          name, and for each keyed name, the value of the custom field is
          assigned. Each pair of custom field name/value is entered as a
          new property on the main dictionary, allowing an easy access to
          them, not nested inside a pretty dark 'customInformation/Values'
          list.

        - Every item on the attrs dictionary gets stripped from trailing
          spaces (useful when users make typos).

        PLEASE REMEMBER! whenever you call postprocess on inherited
        classes you should call this method too, or else you lose the
        effect of the tasks done here.
        """
        try:
            try:
                if self.has_key(self.customFieldName):
                    self[self.customFieldName] = [ c for c in self[self.customFieldName] if c['customField']['state']!="DEACTIVATED" ]
                    for custom in self[self.customFieldName]:
                        field_name = custom['customField']['name']
                        field_id = custom['customField']['id']
                        if custom['customFieldSetGroupIndex'] != -1:
                            field_name += '_'+str(custom['customFieldSetGroupIndex'])
                            field_id += '_'+str(custom['customFieldSetGroupIndex'])
                        custom['name'] = field_name
                        custom['id'] = field_id
                        try:
                            self[field_name] = custom['value']
                            self[field_id] = custom['value']
                        except KeyError:
                            self[field_name] = custom['linkedEntityKeyValue']
                            self[field_id] = custom['linkedEntityKeyValue']
                            custom['value']  = custom['linkedEntityKeyValue']
            # in case you don't have any customFieldName, don't do anything here
            except (AttributeError, TypeError):
                pass

            for k,v in self.items():
                try:
                    self[k] = v.strip()
                except Exception:
                    pass
        except NotImplementedError:
            pass