summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2009-12-03 22:32:40 +0000
committerjortel <devnull@localhost>2009-12-03 22:32:40 +0000
commitbc21ef251cc0454dc61e97c9721934a0dea1b8c8 (patch)
treeae93738b9ae9282f26076d7377bca62a210a0308
parent25830e72cc345b0f641bfd857f2b4bb2b96d1461 (diff)
downloadsuds-bc21ef251cc0454dc61e97c9721934a0dea1b8c8.tar.gz
Fix ticket 278 (again); fix (2) demensional soap encoded arrays. Also, fix handling of dict inside encoded array.
-rw-r--r--suds/__init__.py2
-rw-r--r--suds/mx/encoded.py11
-rw-r--r--suds/mx/literal.py5
-rw-r--r--suds/umx/core.py33
-rw-r--r--suds/umx/encoded.py5
-rw-r--r--suds/umx/typed.py36
-rw-r--r--tests/axis1.py2
-rw-r--r--tests/axis2.py2
8 files changed, 53 insertions, 43 deletions
diff --git a/suds/__init__.py b/suds/__init__.py
index 05843cf..32a2432 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -29,7 +29,7 @@ import sys
#
__version__ = '0.3.8'
-__build__="(beta) R616-20091202"
+__build__="(beta) R617-20091203"
#
# Exceptions
diff --git a/suds/mx/encoded.py b/suds/mx/encoded.py
index 04ec077..18cdec1 100644
--- a/suds/mx/encoded.py
+++ b/suds/mx/encoded.py
@@ -28,7 +28,10 @@ from suds.xsd.query import TypeQuery
log = getLogger(__name__)
-
+#
+# Add encoded extensions
+# aty = The soap (section 5) encoded array type.
+#
Content.extensions.append('aty')
@@ -111,6 +114,12 @@ class Encoded(Literal):
if isinstance(x, (list, tuple, Object)):
array.item.append(x)
continue
+ if isinstance(x, dict):
+ x = Factory.object(ref.name, x)
+ md = x.__metadata__
+ md.sxtype = ref
+ array.item.append(x)
+ continue
x = Factory.property(ref.name, x)
md = x.__metadata__
md.sxtype = ref
diff --git a/suds/mx/literal.py b/suds/mx/literal.py
index 9417571..4c43b47 100644
--- a/suds/mx/literal.py
+++ b/suds/mx/literal.py
@@ -32,6 +32,9 @@ log = getLogger(__name__)
#
# Add typed extensions
+# type = The expected xsd type
+# real = The 'true' XSD type
+# ancestry = The 'type' ancestry
#
Content.extensions.append('type')
Content.extensions.append('real')
@@ -232,6 +235,8 @@ class Typed(Core):
if isinstance(v, dict):
cls = content.real.name
content.value = Factory.object(cls, v)
+ md = content.value.__metadata__
+ md.sxtype = content.type
return
v = content.real.translate(v, False)
content.value = v
diff --git a/suds/umx/core.py b/suds/umx/core.py
index 8f63f87..7fb4ac4 100644
--- a/suds/umx/core.py
+++ b/suds/umx/core.py
@@ -45,8 +45,7 @@ class Core:
@rtype: L{Object}
"""
self.reset()
- data, result = self.append(content)
- return result
+ return self.append(content)
def append(self, content):
"""
@@ -64,7 +63,7 @@ class Core:
self.append_children(content)
self.append_text(content)
self.end(content)
- return content.data, self.postprocess(content)
+ return self.postprocess(content)
def postprocess(self, content):
"""
@@ -94,7 +93,7 @@ class Core:
if content.node.isnil():
return None
if not len(node.children) and content.text is None:
- if self.nillable(content.data):
+ if self.nillable(content):
return None
else:
return Text('', lang=lang)
@@ -138,7 +137,7 @@ class Core:
"""
for child in content.node.children:
cont = Content(child)
- cdata, cval = self.append(cont)
+ cval = self.append(cont)
key = reserved.get(child.name, child.name)
if key in content.data:
v = getattr(content.data, key)
@@ -147,7 +146,7 @@ class Core:
else:
setattr(content.data, key, [v, cval])
continue
- if self.unbounded(cdata):
+ if self.unbounded(cont):
if cval is None:
setattr(content.data, key, [])
else:
@@ -186,31 +185,31 @@ class Core:
"""
pass
- def bounded(self, data):
+ def bounded(self, content):
"""
- Get whether the object is bounded (not a list).
- @param data: The current object being built.
- @type data: L{Object}
+ Get whether the content is bounded (not a list).
+ @param content: The current content being unmarshalled.
+ @type content: L{Content}
@return: True if bounded, else False
@rtype: boolean
'"""
- return ( not self.unbounded(data) )
+ return ( not self.unbounded(content) )
- def unbounded(self, data):
+ def unbounded(self, content):
"""
Get whether the object is unbounded (a list).
- @param data: The current object being built.
- @type data: L{Object}
+ @param content: The current content being unmarshalled.
+ @type content: L{Content}
@return: True if unbounded, else False
@rtype: boolean
'"""
return False
- def nillable(self, data):
+ def nillable(self, content):
"""
Get whether the object is nillable.
- @param data: The current object being built.
- @type data: L{Object}
+ @param content: The current content being unmarshalled.
+ @type content: L{Content}
@return: True if nillable, else False
@rtype: boolean
'"""
diff --git a/suds/umx/encoded.py b/suds/umx/encoded.py
index 49b262f..f613a5c 100644
--- a/suds/umx/encoded.py
+++ b/suds/umx/encoded.py
@@ -26,7 +26,10 @@ from suds.sax import splitPrefix, Namespace
log = getLogger(__name__)
-
+#
+# Add encoded extensions
+# aty = The soap (section 5) encoded array type.
+#
Content.extensions.append('aty')
diff --git a/suds/umx/typed.py b/suds/umx/typed.py
index 3e2eb4b..0db22d7 100644
--- a/suds/umx/typed.py
+++ b/suds/umx/typed.py
@@ -28,7 +28,13 @@ from suds.sudsobject import Factory
log = getLogger(__name__)
+#
+# Add typed extensions
+# type = The expected xsd type
+# real = The 'true' XSD type
+#
Content.extensions.append('type')
+Content.extensions.append('real')
class Typed(Core):
@@ -77,8 +83,9 @@ class Typed(Core):
known = self.resolver.known(content.node)
frame = Frame(content.type, resolved=known)
self.resolver.push(frame)
- resolved = self.resolver.top().resolved
- cls_name = resolved.name
+ real = self.resolver.top().resolved
+ content.real = real
+ cls_name = real.name
if cls_name is None:
cls_name = content.node.name
content.data = Factory.object(cls_name)
@@ -88,26 +95,13 @@ class Typed(Core):
def end(self, content):
self.resolver.pop()
- def unbounded(self, data):
- try:
- if isinstance(data, Object):
- md = data.__metadata__
- type = md.sxtype
- return type.unbounded()
- except:
- log.error('metadata error:\n%s', data, exc_info=True)
- return False
+ def unbounded(self, content):
+ return content.type.unbounded()
- def nillable(self, data):
- try:
- if isinstance(data, Object):
- md = data.__metadata__
- type = md.sxtype
- resolved = type.resolve()
- return ( type.nillable or (resolved.builtin() and resolved.nillable ) )
- except:
- log.error('metadata error:\n%s', data, exc_info=True)
- return False
+ def nillable(self, content):
+ resolved = content.type.resolve()
+ return ( content.type.nillable or \
+ (resolved.builtin() and resolved.nillable ) )
def append_attribute(self, name, value, content):
"""
diff --git a/tests/axis1.py b/tests/axis1.py
index 9d9be01..d06823d 100644
--- a/tests/axis1.py
+++ b/tests/axis1.py
@@ -88,7 +88,7 @@ try:
print '{empty} person=\n%s' % person
person.name = name
person.age = 43
- person.phone = [phoneA,phoneB, phoneC]
+ person.phone = [phoneA,phoneB,phoneC]
person.pets = [dog]
print 'person=\n%s' % person
#
diff --git a/tests/axis2.py b/tests/axis2.py
index 8ed0bdd..966cb7e 100644
--- a/tests/axis2.py
+++ b/tests/axis2.py
@@ -38,7 +38,7 @@ print 'url=%s' % url
#
# create a service client using the wsdl.
#
-client = Client(url)
+client = Client(url, cache=None)
#
# print the service (introspection)