def serialize_entity(self, request, entity):
        """
        @param: entity -> entity object returned by the entity_actions step
        """
        serialized = {}
        fields_to_serialize = self.get_fields_to_serialize(request)
        for field_name, field in fields_to_serialize.items():
            field_override = getattr(self, 'serialize_%s' % field_name, None)
            if field_override:
                serialized_value = field_override(request, entity)
            else:
                entity_attribute = field.entity_attribute or field_name

                try:
                    serialized_value = attribute_getter.get_attribute(
                        entity, entity_attribute)
                except AttributeError as ex:
                    if field.required:
                        raise ex
                    continue

            serialized[field_name] = field.serialize(request, serialized_value)
        return serialized
def serialize_entity ( self , request , entity ) : serialized = { } fields_to_serialize = self . get_fields_to_serialize ( request ) for field_name , field in fields_to_serialize . items ( ) : field_override = getattr ( self , 'serialize_%s' % field_name , None ) if field_override : serialized_value = field_override ( request , entity ) else : entity_attribute = field . entity_attribute or field_name try : serialized_value = attribute_getter . get_attribute ( entity , entity_attribute ) except AttributeError as ex : if field . required : raise ex continue serialized [ field_name ] = field . serialize ( request , serialized_value ) return serialized
@param: entity -> entity object returned by the entity_actions step