summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2009-12-11 01:02:02 +0000
committerjortel <devnull@localhost>2009-12-11 01:02:02 +0000
commit947c48e82f3bc9f247cf7c8925d337260ed4659f (patch)
tree90fe0b13a159a5eb83f305d5b6f6efa15649d70b
parent664b1b8509fcde4de50af3b387e8a865a93a3c1c (diff)
downloadsuds-947c48e82f3bc9f247cf7c8925d337260ed4659f.tar.gz
Add autoblend feature (disabled by default). The feature (option) ensures that all schemas defined in the wsdl import each other. This feature remains experimental because I'm not sure of the side effects. We can enable by default if does not create any problems.
-rw-r--r--suds/__init__.py2
-rw-r--r--suds/options.py7
-rw-r--r--suds/xsd/schema.py29
3 files changed, 36 insertions, 2 deletions
diff --git a/suds/__init__.py b/suds/__init__.py
index 8f8f48d..5215a9c 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -29,7 +29,7 @@ import sys
#
__version__ = '0.3.8'
-__build__="(beta) R620-20091207"
+__build__="(beta) R624-20091210"
#
# Exceptions
diff --git a/suds/options.py b/suds/options.py
index 8b7874a..4179fd0 100644
--- a/suds/options.py
+++ b/suds/options.py
@@ -80,6 +80,10 @@ class Options(Skin):
of the python object graph.
- type: I{bool}
- default: False
+ - B{autoblend} - Flag that ensures that the schema(s) defined within the
+ WSDL import each other.
+ - type: I{bool}
+ - default: False
"""
def __init__(self, **kwargs):
domain = __name__
@@ -94,6 +98,7 @@ class Options(Skin):
Definition('doctor', Doctor, None),
Definition('xstq', bool, True),
Definition('prefixes', bool, True),
- Definition('retxml', bool, False)
+ Definition('retxml', bool, False),
+ Definition('autoblend', bool, False),
]
Skin.__init__(self, domain, definitions, kwargs)
diff --git a/suds/xsd/schema.py b/suds/xsd/schema.py
index c57743f..e4f0515 100644
--- a/suds/xsd/schema.py
+++ b/suds/xsd/schema.py
@@ -25,12 +25,14 @@ tranparent referenced type resolution and targeted denormalization.
from logging import getLogger
import suds.metrics
from suds import *
+from suds.metrics import Timer
from suds.xsd import *
from suds.xsd.sxbuiltin import *
from suds.xsd.sxbasic import Factory as BasicFactory
from suds.xsd.sxbuiltin import Factory as BuiltinFactory
from suds.xsd.sxbase import SchemaObject
from suds.xsd.deplist import DepList
+from suds.sax.element import Element
from suds.sax import splitPrefix, Namespace
log = getLogger(__name__)
@@ -84,6 +86,8 @@ class SchemaCollection:
@return: The merged schema.
@rtype: L{Schema}
"""
+ if self.options.autoblend:
+ self.autoblend()
for child in self.children:
child.build()
for child in self.children:
@@ -95,6 +99,31 @@ class SchemaCollection:
log.debug('MERGED:\n%s', merged)
return merged
+ def autoblend(self):
+ """
+ Ensure that all schemas within the collection
+ import each other which has a blending effect.
+ @return: self
+ @rtype: L{SchemaCollection}
+ """
+ timer = Timer()
+ timer.start()
+ namespaces = self.namespaces.keys()
+ for s in self.children:
+ for ns in namespaces:
+ tns = s.root.get('targetNamespace')
+ if tns == ns:
+ continue
+ for imp in s.root.getChildren('import'):
+ if imp.get('namespace') == ns:
+ continue
+ imp = Element('import', ns=Namespace.xsdns)
+ imp.set('namespace', ns)
+ s.root.append(imp)
+ timer.stop()
+ print timer.duration()
+ return self
+
def locate(self, ns):
"""
Find a schema by namespace. Only the URI portion of