Browse Source

adding maptype

main
Sandro Knauß 12 years ago
committed by Mathieu Le Marec - Pasquet
parent
commit
2a1964e423
3 changed files with 58 additions and 0 deletions
  1. +1
    -0
      src/SOAPpy/Config.py
  2. +47
    -0
      src/SOAPpy/SOAPBuilder.py
  3. +10
    -0
      src/SOAPpy/Types.py

+ 1
- 0
src/SOAPpy/Config.py View File

@@ -77,6 +77,7 @@ class SOAPConfig:
self.strictNamespaces = 0
self.typed = 1
self.buildWithNamespacePrefix = 1
self.buildWithGlobalNamespacePrefix = False
self.returnAllAttrs = 0

# Strict checking of range for floats and doubles


+ 47
- 0
src/SOAPpy/SOAPBuilder.py View File

@@ -227,6 +227,9 @@ class SOAPBuilder:
ns_map[nsURI] = ns
if self.config.buildWithNamespacePrefix:
return (ns + ':', ' xmlns:%s="%s"' % (ns, nsURI))
elif self.config.buildWithGlobalNamespacePrefix:
self.envns[nsURI] = ns
return (ns + ':', '')
else:
return ('', ' xmlns="%s"' % (nsURI))

@@ -509,6 +512,49 @@ class SOAPBuilder:

dump_tuple = dump_list

def dump_map(self, obj, tag, typed = 1, ns_map = {}):
if Config.debug: print "In dump_map.", "obj=", obj
tag = tag or self.gentag()
tag = toXMLname(tag) # convert from SOAP 1.2 XML name encoding

if type(obj) == InstanceType:
data = obj.data
else:
data = obj

if typed:
id = self.checkref(obj, tag, ns_map)
if id == None:
return

try: a = obj._marshalAttrs(ns_map, self)
except: a = ''

ndecl = ''
ens, edecl = self.genns(ns_map, 'http://xml.apache.org/xml-soap')
ins, idecl = self.genns(ns_map, self.config.schemaNamespaceURI)

if typed:
self.out.append(
'<%s %stype="%sMap"%s%s%s%s%s%s>\n' %
(tag, ins, ens, ndecl, edecl, idecl,
self.genroot(ns_map), id, a))

try: elemsname = obj._elemsname
except: elemsname = "item"
else:
elemsname = tag
if isinstance(data, (list, tuple, arrayType)):
should_drill = True
else:
should_drill = not same_type
for i in data:
self.dump(i, elemsname, should_drill, ns_map)

if typed: self.out.append('</%s>\n' % tag)

def dump_exception(self, obj, tag, typed = 0, ns_map = {}):
if isinstance(obj, faultType): # Fault
cns, cdecl = self.genns(ns_map, NS.ENC)
@@ -554,6 +600,7 @@ class SOAPBuilder:
# watch out for order!
dumpmap = (
(Exception, self.dump_exception),
(mapType, self.dump_map),
(arrayType, self.dump_list),
(basestring, self.dump_string),
(NoneType, self.dump_None),


+ 10
- 0
src/SOAPpy/Types.py View File

@@ -1562,6 +1562,16 @@ class arrayType(UserList.UserList, compoundType):

a[curpos[0]] = value

class mapType(arrayType):
_validURIs = ('http://xml.apache.org/xml-soap',)

def __init__(self, data = None, name = None, attrs = None,
offset = 0, rank = None, asize = 0, elemsname = None):
arrayType.__init__(self, data, name, attrs, offset, rank, asize,
elemsname)
self._keyord=['key','value']

class typedArrayType(arrayType):
def __init__(self, data = None, name = None, typed = None, attrs = None,
offset = 0, rank = None, asize = 0, elemsname = None, complexType = 0):


Loading…
Cancel
Save