--- /dev/null
+# Import etree from anywhere
+try:
+ # lxml http://codespeak.net/lxml/
+ from lxml import etree
+
+ # Define register_namespace function and ElementRoot for proper serialization
+ NSMAP = {}
+ def register_namespace(prefix, uri):
+ NSMAP[prefix] = uri
+
+ def ElementRoot(*args, **kwargs):
+ kwargs['nsmap'] = NSMAP
+ return etree.Element(*args, **kwargs)
+
+except ImportError:
+ try:
+ # normal cElementTree install
+ import cElementTree as etree
+ except ImportError:
+ # normal ElementTree install
+ import elementtree.ElementTree as etree
+
+ try:
+ register_namespace = ET.register_namespace
+ except AttributeError:
+ def register_namespace(prefix, uri):
+ ET._namespace_map[uri] = prefix
+
+ def ElementRoot(*args, **kwargs):
+ return etree.Element(*args, **kwargs)
+
+__all__ = ('etree', 'register_namespace', 'ElementRoot')
from django.conf import settings
from django.core.urlresolvers import get_callable
-from cas_provider.xml import etree, register_namespace, ElementRoot
+from cas_provider.etree import etree, register_namespace, ElementRoot
class ServiceTicket(models.Model):
user = models.ForeignKey(User)
+++ /dev/null
-# Import etree from anywhere
-try:
- # lxml http://codespeak.net/lxml/
- from lxml import etree
-
- # Define register_namespace function and ElementRoot for proper serialization
- NSMAP = {}
- def register_namespace(prefix, uri):
- NSMAP[prefix] = uri
-
- def ElementRoot(*args, **kwargs):
- kwargs['nsmap'] = NSMAP
- return etree.Element(*args, **kwargs)
-
-except ImportError:
- try:
- # Python 2.5
- import xml.etree.cElementTree as etree
- except ImportError:
- try:
- # Python 2.5
- import xml.etree.ElementTree as etree
- except ImportError:
- try:
- # normal cElementTree install
- import cElementTree as etree
- except ImportError:
- # normal ElementTree install
- import elementtree.ElementTree as etree
-
- try:
- register_namespace = ET.register_namespace
- except AttributeError:
- def register_namespace(prefix, uri):
- ET._namespace_map[uri] = prefix
-
- def ElementRoot(*args, **kwargs):
- return etree.Element(*args, **kwargs)
-
-__all__ = ('etree', 'register_namespace', 'ElementRoot')