# Path: easymode/utils/xmlutils.py
# def _unicode_for_entity_with_name(name):
# def unescape_all(string):
#     def escape_single(matchobj):
# def is_valid(xml_string):
#     def __init__(self, *args, **kwargs):
#             def resolveEntity(self, publicId, systemId):
#     def reset(self):
#     def skippedEntity(self, name):
# def create_parser(*args, **kwargs):
# class XmlScanner(ExpatParser):
#         class _NiftyEntityResolver(EntityResolver):
# class XmlPrinter(SimplerXMLGenerator):


import logging
import os
import re
import warnings
    import tinymce
from StringIO import StringIO
from time import time
from urllib import urlopen
from xml import sax
from django.conf import settings
from django.contrib.admin.widgets import AdminTextInputWidget, AdminTextareaWidget
from django.db import connection, models
from django.db.models import CharField, TextField
from django.forms import fields
from django.utils.datastructures import DictWrapper
from django.utils.translation import ugettext_lazy as _
from tinymce.widgets import TinyMCE
from easymode.admin.forms import fields as form_fields
from easymode.utils import xmlutils
    5. accepts tinymce configuration options.

    usage::

        html = SafeHTMLField(_('some rich text'), max_length=200, width=300, height=100, buttons="link,unlink,code")

    :param max_length: The maximum length of the text, after stripping markup and
        converting html entities to normal characters.
    :param width: The width of the html editor in the admin
    :param height: The height of the html editor in the admin
    :param buttons: Configuration for the 
        `theme_advanced_buttons1 <http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/theme_advanced_buttons_1_n>`_. 
        The default is "bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat".
    """
    _south_introspects = True

    def __init__(self, *args, **kwargs):
        mce_config = DEFAULT_MCE_CONFIG or \
            "bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat"
        
        self.mce_width = kwargs.pop('width', 340)
        self.mce_height = kwargs.pop('height', 160)
        self.buttons = kwargs.pop('buttons', mce_config)
        
        super(SafeHTMLField, self).__init__(*args, **kwargs)

    def __serialize__(self, obj, xml):
        richtext = self.value_to_string(obj)
        value = u"<richtext>%s</richtext>"  % richtext


# Path: easymode/utils/xmlutils.py
# def _unicode_for_entity_with_name(name):
# def unescape_all(string):
#     def escape_single(matchobj):
# def is_valid(xml_string):
#     def __init__(self, *args, **kwargs):
#             def resolveEntity(self, publicId, systemId):
#     def reset(self):
#     def skippedEntity(self, name):
# def create_parser(*args, **kwargs):
# class XmlScanner(ExpatParser):
#         class _NiftyEntityResolver(EntityResolver):
# class XmlPrinter(SimplerXMLGenerator):


# Path: easymode/admin/models/fields.py
import logging
import os
import re
import warnings
    import tinymce
from StringIO import StringIO
from time import time
from urllib import urlopen
from xml import sax
from django.conf import settings
from django.contrib.admin.widgets import AdminTextInputWidget, AdminTextareaWidget
from django.db import connection, models
from django.db.models import CharField, TextField
from django.forms import fields
from django.utils.datastructures import DictWrapper
from django.utils.translation import ugettext_lazy as _
from tinymce.widgets import TinyMCE
from easymode.admin.forms import fields as form_fields
from easymode.utils import xmlutils

    5. accepts tinymce configuration options.

    usage::

        html = SafeHTMLField(_('some rich text'), max_length=200, width=300, height=100, buttons="link,unlink,code")

    :param max_length: The maximum length of the text, after stripping markup and
        converting html entities to normal characters.
    :param width: The width of the html editor in the admin
    :param height: The height of the html editor in the admin
    :param buttons: Configuration for the 
        `theme_advanced_buttons1 <http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/theme_advanced_buttons_1_n>`_. 
        The default is "bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat".
    """
    _south_introspects = True

    def __init__(self, *args, **kwargs):
        mce_config = DEFAULT_MCE_CONFIG or \
            "bullist,numlist,|,undo,redo,|,link,unlink,|,code,|,cleanup,removeformat"
        
        self.mce_width = kwargs.pop('width', 340)
        self.mce_height = kwargs.pop('height', 160)
        self.buttons = kwargs.pop('buttons', mce_config)
        
        super(SafeHTMLField, self).__init__(*args, **kwargs)

    def __serialize__(self, obj, xml):
        richtext = self.value_to_string(obj)
        value = u"<richtext>%s</richtext>"  % richtext


        if xmlutils.is_valid(value):