Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Fix building xsd types using the builder with mixed content (string w…
Browse files Browse the repository at this point in the history
…/ attributes).

git-svn-id: http://svn.fedorahosted.org/svn/suds/trunk@686 0b8c961e-115e-4cb0-8d11-a7d6dae58e8c
  • Loading branch information
jortel committed Aug 17, 2010
1 parent 1c772d3 commit ba8f142
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
19 changes: 12 additions & 7 deletions suds/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def build(self, name):
else:
type = name
cls = type.name
if len(type):
data = Factory.object(cls)
else:
if type.mixed():
data = Factory.property(cls)
else:
data = Factory.object(cls)
resolved = type.resolve()
md = data.__metadata__
md.sxtype = resolved
Expand All @@ -73,10 +73,15 @@ def process(self, data, type, history):
value = []
else:
if len(resolved) > 0:
value = Factory.object(resolved.name)
md = value.__metadata__
md.sxtype = resolved
md.ordering = self.ordering(resolved)
if resolved.mixed():
value = Factory.property(resolved.name)
md = value.__metadata__
md.sxtype = resolved
else:
value = Factory.object(resolved.name)
md = value.__metadata__
md.sxtype = resolved
md.ordering = self.ordering(resolved)
setattr(data, type.name, value)
if value is not None:
data = value
Expand Down
6 changes: 6 additions & 0 deletions suds/xsd/sxbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ def restriction(self):
@rtype: boolean
"""
return False

def mixed(self):
"""
Get whether this I{mixed} content.
"""
return False

def find(self, qref, classes=()):
"""
Expand Down
14 changes: 13 additions & 1 deletion suds/xsd/sxbasic.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def extension(self):
if c.extension():
return True
return False

def mixed(self):
for c in self.rawchildren:
if isinstance(c, SimpleContent) and c.mixed():
return True
return False


class Group(SchemaObject):
Expand Down Expand Up @@ -195,6 +201,9 @@ def enum(self):
if isinstance(child, Enumeration):
return True
return False

def mixed(self):
return len(self)

def description(self):
return ('name',)
Expand Down Expand Up @@ -340,6 +349,9 @@ def restriction(self):
if c.restriction():
return True
return False

def mixed(self):
return len(self)


class Enumeration(Content):
Expand Down Expand Up @@ -470,7 +482,7 @@ def extension(self):

def description(self):
return ('ref',)


class Import(SchemaObject):
"""
Expand Down

0 comments on commit ba8f142

Please sign in to comment.