# Path: dockit/core/serializers/base.py
# class Serializer(object):
# class Deserializer(object):
# class UnSet:
# class DeserializedObject(object):
#     def serialize(self, queryset, **options):
#     def start_serialization(self):
#     def end_serialization(self):
#     def start_object(self, obj):
#     def end_object(self, obj):
#     def getvalue(self):
#     def __init__(self, stream_or_string, **options):
#     def __iter__(self):
#     def next(self):
#     def __init__(self, obj, natural_key=UnSet):
#     def __repr__(self):
#     def save(self, enforce_natural_key=True):


from django.conf import settings
from dockit.core.serializers import base
from django.db import models, DEFAULT_DB_ALIAS
from django.utils.xmlutils import SimplerXMLGenerator
from django.utils.encoding import smart_unicode
from xml.dom import pulldom
                def handle_m2m(value):
                    natural = value.natural_key()
                    # Iterable natural keys are rolled out as subelements
                    self.xml.startElement("object", {})
                    for key_value in natural:
                        self.xml.startElement("natural", {})
                        self.xml.characters(smart_unicode(key_value))
                        self.xml.endElement("natural")
                    self.xml.endElement("object")
            else:
                def handle_m2m(value):
                    self.xml.addQuickElement("object", attrs={
                        'pk' : smart_unicode(value._get_pk_val())
                    })
            for relobj in getattr(obj, field.name).iterator():
                handle_m2m(relobj)

            self.xml.endElement("field")

    def _start_relational_field(self, field):
        """
        Helper to output the <field> element for relational fields
        """
        self.indent(2)
        self.xml.startElement("field", {
            "name" : field.name,
            "rel"  : field.rel.__class__.__name__,
            "to"   : smart_unicode(field.rel.to._meta),
        })


# Path: dockit/core/serializers/base.py
# class Serializer(object):
# class Deserializer(object):
# class UnSet:
# class DeserializedObject(object):
#     def serialize(self, queryset, **options):
#     def start_serialization(self):
#     def end_serialization(self):
#     def start_object(self, obj):
#     def end_object(self, obj):
#     def getvalue(self):
#     def __init__(self, stream_or_string, **options):
#     def __iter__(self):
#     def next(self):
#     def __init__(self, obj, natural_key=UnSet):
#     def __repr__(self):
#     def save(self, enforce_natural_key=True):


# Path: dockit/core/serializers/xml_serializer.py
from django.conf import settings
from dockit.core.serializers import base
from django.db import models, DEFAULT_DB_ALIAS
from django.utils.xmlutils import SimplerXMLGenerator
from django.utils.encoding import smart_unicode
from xml.dom import pulldom

                def handle_m2m(value):
                    natural = value.natural_key()
                    # Iterable natural keys are rolled out as subelements
                    self.xml.startElement("object", {})
                    for key_value in natural:
                        self.xml.startElement("natural", {})
                        self.xml.characters(smart_unicode(key_value))
                        self.xml.endElement("natural")
                    self.xml.endElement("object")
            else:
                def handle_m2m(value):
                    self.xml.addQuickElement("object", attrs={
                        'pk' : smart_unicode(value._get_pk_val())
                    })
            for relobj in getattr(obj, field.name).iterator():
                handle_m2m(relobj)

            self.xml.endElement("field")

    def _start_relational_field(self, field):
        """
        Helper to output the <field> element for relational fields
        """
        self.indent(2)
        self.xml.startElement("field", {
            "name" : field.name,
            "rel"  : field.rel.__class__.__name__,
            "to"   : smart_unicode(field.rel.to._meta),
        })


class Deserializer(base.Deserializer):