indivo.serializers package¶
Submodules¶
indivo.serializers.base module¶
Module for abstract serializer base classes.
Differentiated from the Django base serializer by allowing implementing serializers to process nested objects. Recursion is prevented by keeping track of visited objects, and results in repeated objects being skipped after their first appearance
- class indivo.serializers.base.DeserializedObject(obj, m2m_data=None)¶
Bases: object
Deserialization is not currently supported
- save(save_m2m=True)¶
- class indivo.serializers.base.Deserializer(stream_or_string, **options)¶
Bases: object
Deserialization is not supported
- exception indivo.serializers.base.SerializationRecursionError¶
Bases: exceptions.Exception
Object encountered twice during serialization
- class indivo.serializers.base.Serializer¶
Bases: django.core.serializers.base.Serializer
Abstract serializer base class.
- handle_o2m_field(obj, current, field_name)¶
Called to handle a OneToMany field.
- internal_use_only = False¶
- process_object(obj)¶
- process_objects(objects)¶
- serialize(queryset, **options)¶
Serialize a queryset.
indivo.serializers.datamodel_hooks module¶
- class indivo.serializers.datamodel_hooks.DataModelSerializers¶
Bases: object
Abstract base class for defining serializers that should be attached to a data model class.
Serializers will override the default implementations. Subclasses should define any of three methods:
- to_rdf(queryset, result_count, record=None, carenet=None): takes a queryset, and formats it as valid RDF/XML string.
- to_xml(queryset, result_count, record=None, carenet=None): takes a queryset, and formats it as a valid XML string.
- to_json(queryset, result_count, record=None, carenet=None): takes a queryset, and formats it as a valid JSON string.
In order to be called, the methods must be attached to that data model class by calling the attach_to_data_model() method.
- classmethod attach_to_data_model(data_model_cls)¶
Add all of the defined methods as classmethods on data_model_cls.
indivo.serializers.json module¶
Indivo JSON Serializer
- class indivo.serializers.json.IndivoJSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)¶
Bases: json.encoder.JSONEncoder
Encodes datetime/date/time as ISO8601
- default(o)¶
- class indivo.serializers.json.Serializer¶
Bases: indivo.serializers.python.Serializer
Convert a queryset to JSON.
- end_serialization()¶
- getvalue()¶
- internal_use_only = False¶
indivo.serializers.python module¶
Indivo Python Serializer
- indivo.serializers.python.Deserializer(object_list, **options)¶
Deserialization is not currently supported
- class indivo.serializers.python.Serializer¶
Bases: indivo.serializers.base.Serializer
Serializes a QuerySet to basic Python objects. - Parses foreign key and many-to-many fields into nested objects - Output mirrors Indivo SDML format
- end_object(obj)¶
- end_serialization()¶
- getvalue()¶
- handle_field(obj, field)¶
- handle_fk_field(obj, field)¶
- handle_m2m_field(obj, field)¶
- handle_o2m_field(obj, field_name)¶
- internal_use_only = True¶
- start_object(obj)¶
- start_serialization()¶
indivo.serializers.xml_serializer module¶
Indivo custom XML serializer
- class indivo.serializers.xml_serializer.Deserializer(stream_or_string, **options)¶
Bases: indivo.serializers.base.Deserializer
Deserialization is not currently supported
- class indivo.serializers.xml_serializer.Serializer¶
Bases: indivo.serializers.base.Serializer
Serializes a QuerySet to XML. Foreign Key and Many-to-Many fields are processed as sub-objects.
- end_object(obj)¶
Called after handling all fields for an object.
- end_serialization()¶
End serialization – end the document.
- getvalue()¶
- handle_field(obj, field)¶
Called to handle each field on an object (except for ForeignKeys and ManyToManyFields)
- handle_fk_field(obj, field)¶
Called to handle a ForeignKey (we need to treat them slightly differently from regular fields).
- handle_m2m_field(obj, field)¶
Called to handle a ManyToManyField.
- handle_o2m_field(obj, field_name)¶
- start_object(obj)¶
Called as each object is handled.
- start_serialization()¶
Start serialization
Module contents¶
Indivo serializers