# Path: easymode/utils/xmlutils.py
# class XmlPrinter(SimplerXMLGenerator):
#     """
#     XmlPrinter can be used as a contenthandler for the 
#     :class:`~easymode.utils.xmlutils.XmlScanner`.
#     
#     It will convert all skippedEntities to their unicode characters
#     and copy these to the output stream.
#     
#     You can use it as a simple xml generator, to create xml::
#     
#         stream = StringIO.StringIO()
#         xml = XmlPrinter(stream, settings.DEFAULT_CHARSET)
# 
#         def _render_page(page):
#             xml.startElement('title', {})
#             xml.characters(page.title)
#             xml.endElement('title')
#             xml.startElement('template', {})
#             xml.characters(page.template)
#             xml.endElement('template')
#         
#         for child in Page.children.all():
#             xml.startElement('page', {})
#             _render_page(child)
#             xml.endElement('page')
#     """
#     def skippedEntity(self, name):
#         self._out.write(_unicode_for_entity_with_name(name).encode('utf-8'))


import sys
from StringIO import StringIO
from django.conf import settings
from django.core.serializers import xml_serializer
from django.utils.encoding import smart_unicode, force_unicode
from easymode.tree.introspection import get_default_field_descriptors, \
    get_foreign_key_desciptors, get_generic_relation_descriptors
from easymode.utils import recursion_depth
from easymode.utils.xmlutils import XmlPrinter
"""
Contains an instance of Serializer and extends it to allow for recusive
serialization of django models with foreign keys.
"""




MANY_TO_MANY_RECURSION_LIMIT_ERROR = """
Deep recursion in easymode.tree.xml.serializers.RecursiveXmlSerializer:
Serializer found ManyToManyField named: %s from %s to %s.

You probably built a cycle in your model tree using many to many relations.
Please inspect the stack trace and try to fix the problem.

If you are sure these is no cycle and you just have lots and lots of models

# Path: easymode/utils/xmlutils.py
# class XmlPrinter(SimplerXMLGenerator):
#     """
#     XmlPrinter can be used as a contenthandler for the 
#     :class:`~easymode.utils.xmlutils.XmlScanner`.
#     
#     It will convert all skippedEntities to their unicode characters
#     and copy these to the output stream.
#     
#     You can use it as a simple xml generator, to create xml::
#     
#         stream = StringIO.StringIO()
#         xml = XmlPrinter(stream, settings.DEFAULT_CHARSET)
# 
#         def _render_page(page):
#             xml.startElement('title', {})
#             xml.characters(page.title)
#             xml.endElement('title')
#             xml.startElement('template', {})
#             xml.characters(page.template)
#             xml.endElement('template')
#         
#         for child in Page.children.all():
#             xml.startElement('page', {})
#             _render_page(child)
#             xml.endElement('page')
#     """
#     def skippedEntity(self, name):
#         self._out.write(_unicode_for_entity_with_name(name).encode('utf-8'))


# Path: easymode/tree/xml/serializers.py
import sys
from StringIO import StringIO
from django.conf import settings
from django.core.serializers import xml_serializer
from django.utils.encoding import smart_unicode, force_unicode
from easymode.tree.introspection import get_default_field_descriptors, \
    get_foreign_key_desciptors, get_generic_relation_descriptors
from easymode.utils import recursion_depth
from easymode.utils.xmlutils import XmlPrinter

"""
Contains an instance of Serializer and extends it to allow for recusive
serialization of django models with foreign keys.
"""




MANY_TO_MANY_RECURSION_LIMIT_ERROR = """
Deep recursion in easymode.tree.xml.serializers.RecursiveXmlSerializer:
Serializer found ManyToManyField named: %s from %s to %s.

You probably built a cycle in your model tree using many to many relations.
Please inspect the stack trace and try to fix the problem.

If you are sure these is no cycle and you just have lots and lots of models

with a gigantic deep tree, you can also try to set settings.RECURSION_LIMIT to