Browse Source

make it run under 2.5 and above

main
jeffkit 14 years ago
parent
commit
f7f6b52f03
2 changed files with 30 additions and 30 deletions
  1. +14
    -14
      SOAPpy/Client.py
  2. +16
    -16
      SOAPpy/Types.py

+ 14
- 14
SOAPpy/Client.py View File

@@ -39,11 +39,11 @@
#
################################################################################
"""
from __future__ import nested_scopes

ident = '$Id: Client.py,v 1.27 2005/02/21 20:27:09 warnes Exp $'
from version import __version__

from __future__ import nested_scopes

#import xml.sax
import urllib
@@ -125,7 +125,7 @@ class HTTPTransport:
return original_namespace
else:
return original_namespace
# Need a Timeout someday?
def call(self, addr, data, namespace, soapaction = None, encoding = None,
http_proxy = None, config = Config):
@@ -164,7 +164,7 @@ class HTTPTransport:
# if user is not a user:passwd format
# we'll receive a failure from the server. . .I guess (??)
if addr.user != None:
val = base64.encodestring(addr.user)
val = base64.encodestring(addr.user)
r.putheader('Authorization','Basic ' + val.replace('\012',''))

# This fixes sending either "" or "None"
@@ -218,7 +218,7 @@ class HTTPTransport:
message_len = int(content_length)
except:
message_len = -1
if message_len < 0:
# Content-Length missing or invalid; just read the whole socket
# This won't work with HTTP/1.1 chunked encoding
@@ -233,7 +233,7 @@ class HTTPTransport:
print "headers=", headers
print "content-type=", content_type
print "data=", data
if config.dumpHeadersIn:
s = 'Incoming HTTP headers'
debugHeader(s)
@@ -246,7 +246,7 @@ class HTTPTransport:

def startswith(string, val):
return string[0:len(val)] == val
if code == 500 and not \
( startswith(content_type, "text/xml") and message_len > 0 ):
raise HTTPError(code, msg)
@@ -268,7 +268,7 @@ class HTTPTransport:
new_ns = None
else:
new_ns = self.getNS(namespace, data)
# return response payload
return data, new_ns

@@ -316,10 +316,10 @@ class SOAPProxy:
self.channel_mode = config.channel_mode
self.delegation_mode = config.delegation_mode
#end GSI Additions
def invoke(self, method, args):
return self.__call(method, args, {})
def __call(self, name, args, kw, ns = None, sa = None, hd = None,
ma = None):

@@ -334,7 +334,7 @@ class SOAPProxy:
sa = self.soapaction
else:
sa = name
if hd: # Get header
if type(hd) == TupleType:
hd = hd[0]
@@ -368,7 +368,7 @@ class SOAPProxy:
#
# See if we have a fault handling vector installed in our
# config. If we do, invoke it. If it returns a true value,
# retry the call.
# retry the call.
#
# In any circumstance other than the fault handler returning
# true, reraise the exception. This keeps the semantics of this
@@ -390,7 +390,7 @@ class SOAPProxy:
encoding = self.encoding,
http_proxy = self.http_proxy,
config = self.config)

p, attrs = parseSOAPRPC(r, attrs = 1)

@@ -418,7 +418,7 @@ class SOAPProxy:
count += 1
t = getattr(p, i)
if count == 1: # Only one piece of data, bubble it up
p = t
p = t
except:
pass

@@ -468,7 +468,7 @@ class SOAPProxy:
return self.__f_call(*args, **kw)
else:
return self.__r_call(*args, **kw)
def __getattr__(self, name):
if name == '__del__':
raise AttributeError, name


+ 16
- 16
SOAPpy/Types.py View File

@@ -32,11 +32,11 @@
#
################################################################################
"""
from __future__ import nested_scopes

ident = '$Id: Types.py,v 1.19 2005/02/22 04:29:43 warnes Exp $'
from version import __version__

from __future__ import nested_scopes

import UserList
import base64
@@ -76,7 +76,7 @@ class anyType:
else:
self._ns = self._validURIs[0]
self._name = name
self._typed = typed
self._attrs = {}

@@ -142,7 +142,7 @@ class anyType:
value = unicode(value)

self._attrs[attr] = value

def _setAttrs(self, attrs):
if type(attrs) in (ListType, TupleType):
@@ -1275,7 +1275,7 @@ class compoundType(anyType):
retval[name] = getattr(self,name)
return retval

def __getitem__(self, item):
if type(item) == IntType:
return self.__dict__[self._keyord[item]]
@@ -1300,7 +1300,7 @@ class compoundType(anyType):
else:
self.__dict__[name] = value
self._keyord.append(name)
def _placeItem(self, name, value, pos, subpos = 0, attrs = None):

if subpos == 0 and type(self.__dict__[name]) != ListType:
@@ -1421,10 +1421,10 @@ class arrayType(UserList.UserList, compoundType):
else:
retval = {}
def fun(x): retval[str(x).encode(encoding)] = self.data[x]
map( fun, range(len(self.data)) )
return retval
def __getitem__(self, item):
try:
return self.data[int(item)]
@@ -1589,7 +1589,7 @@ class faultType(structType, Error):
__str__ = __repr__

def __call__(self):
return (self.faultcode, self.faultstring, self.detail)
return (self.faultcode, self.faultstring, self.detail)

class SOAPException(Exception):
def __init__(self, code="", string="", detail=None):
@@ -1630,7 +1630,7 @@ class MethodFailed(Exception):

def __str__(self):
return repr(self.value)
#######
# Convert complex SOAPpy objects to native python equivalents
#######
@@ -1642,16 +1642,16 @@ def simplify(object, level=0):
This function recursively converts the passed 'container' object,
and all public subobjects. (Private subobjects have names that
start with '_'.)
Conversions:
- faultType --> raise python exception
- arrayType --> array
- compoundType --> dictionary
"""
if level > 10:
return object
if isinstance( object, faultType ):
if object.faultstring == "Required Header Misunderstood":
raise RequiredHeaderMismatch(object.detail)
@@ -1695,13 +1695,13 @@ def simplify_contents(object, level=0):

This function recursively converts the sub-objects contained in a
'container' object to simple python types.
Conversions:
- faultType --> raise python exception
- arrayType --> array
- compoundType --> dictionary
"""
if level>10: return object

if isinstance( object, faultType ):
@@ -1709,7 +1709,7 @@ def simplify_contents(object, level=0):
if isPublic(k):
setattr(object, k, simplify(object[k], level=level+1))
raise object
elif isinstance( object, arrayType ):
elif isinstance( object, arrayType ):
data = object._aslist()
for k in range(len(data)):
object[k] = simplify(data[k], level=level+1)
@@ -1730,7 +1730,7 @@ def simplify_contents(object, level=0):
elif type(object)==list:
for k in range(len(object)):
object[k] = simplify(object[k])
return object



Loading…
Cancel
Save