| @@ -39,11 +39,11 @@ | |||||
| # | # | ||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: Client.py,v 1.27 2005/02/21 20:27:09 warnes Exp $' | ident = '$Id: Client.py,v 1.27 2005/02/21 20:27:09 warnes Exp $' | ||||
| from version import __version__ | from version import __version__ | ||||
| from __future__ import nested_scopes | |||||
| #import xml.sax | #import xml.sax | ||||
| import urllib | import urllib | ||||
| @@ -125,7 +125,7 @@ class HTTPTransport: | |||||
| return original_namespace | return original_namespace | ||||
| else: | else: | ||||
| return original_namespace | return original_namespace | ||||
| # Need a Timeout someday? | # Need a Timeout someday? | ||||
| def call(self, addr, data, namespace, soapaction = None, encoding = None, | def call(self, addr, data, namespace, soapaction = None, encoding = None, | ||||
| http_proxy = None, config = Config): | http_proxy = None, config = Config): | ||||
| @@ -164,7 +164,7 @@ class HTTPTransport: | |||||
| # if user is not a user:passwd format | # if user is not a user:passwd format | ||||
| # we'll receive a failure from the server. . .I guess (??) | # we'll receive a failure from the server. . .I guess (??) | ||||
| if addr.user != None: | if addr.user != None: | ||||
| val = base64.encodestring(addr.user) | |||||
| val = base64.encodestring(addr.user) | |||||
| r.putheader('Authorization','Basic ' + val.replace('\012','')) | r.putheader('Authorization','Basic ' + val.replace('\012','')) | ||||
| # This fixes sending either "" or "None" | # This fixes sending either "" or "None" | ||||
| @@ -218,7 +218,7 @@ class HTTPTransport: | |||||
| message_len = int(content_length) | message_len = int(content_length) | ||||
| except: | except: | ||||
| message_len = -1 | message_len = -1 | ||||
| if message_len < 0: | if message_len < 0: | ||||
| # Content-Length missing or invalid; just read the whole socket | # Content-Length missing or invalid; just read the whole socket | ||||
| # This won't work with HTTP/1.1 chunked encoding | # This won't work with HTTP/1.1 chunked encoding | ||||
| @@ -233,7 +233,7 @@ class HTTPTransport: | |||||
| print "headers=", headers | print "headers=", headers | ||||
| print "content-type=", content_type | print "content-type=", content_type | ||||
| print "data=", data | print "data=", data | ||||
| if config.dumpHeadersIn: | if config.dumpHeadersIn: | ||||
| s = 'Incoming HTTP headers' | s = 'Incoming HTTP headers' | ||||
| debugHeader(s) | debugHeader(s) | ||||
| @@ -246,7 +246,7 @@ class HTTPTransport: | |||||
| def startswith(string, val): | def startswith(string, val): | ||||
| return string[0:len(val)] == val | return string[0:len(val)] == val | ||||
| if code == 500 and not \ | if code == 500 and not \ | ||||
| ( startswith(content_type, "text/xml") and message_len > 0 ): | ( startswith(content_type, "text/xml") and message_len > 0 ): | ||||
| raise HTTPError(code, msg) | raise HTTPError(code, msg) | ||||
| @@ -268,7 +268,7 @@ class HTTPTransport: | |||||
| new_ns = None | new_ns = None | ||||
| else: | else: | ||||
| new_ns = self.getNS(namespace, data) | new_ns = self.getNS(namespace, data) | ||||
| # return response payload | # return response payload | ||||
| return data, new_ns | return data, new_ns | ||||
| @@ -316,10 +316,10 @@ class SOAPProxy: | |||||
| self.channel_mode = config.channel_mode | self.channel_mode = config.channel_mode | ||||
| self.delegation_mode = config.delegation_mode | self.delegation_mode = config.delegation_mode | ||||
| #end GSI Additions | #end GSI Additions | ||||
| def invoke(self, method, args): | def invoke(self, method, args): | ||||
| return self.__call(method, args, {}) | return self.__call(method, args, {}) | ||||
| def __call(self, name, args, kw, ns = None, sa = None, hd = None, | def __call(self, name, args, kw, ns = None, sa = None, hd = None, | ||||
| ma = None): | ma = None): | ||||
| @@ -334,7 +334,7 @@ class SOAPProxy: | |||||
| sa = self.soapaction | sa = self.soapaction | ||||
| else: | else: | ||||
| sa = name | sa = name | ||||
| if hd: # Get header | if hd: # Get header | ||||
| if type(hd) == TupleType: | if type(hd) == TupleType: | ||||
| hd = hd[0] | hd = hd[0] | ||||
| @@ -368,7 +368,7 @@ class SOAPProxy: | |||||
| # | # | ||||
| # See if we have a fault handling vector installed in our | # See if we have a fault handling vector installed in our | ||||
| # config. If we do, invoke it. If it returns a true value, | # 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 | # In any circumstance other than the fault handler returning | ||||
| # true, reraise the exception. This keeps the semantics of this | # true, reraise the exception. This keeps the semantics of this | ||||
| @@ -390,7 +390,7 @@ class SOAPProxy: | |||||
| encoding = self.encoding, | encoding = self.encoding, | ||||
| http_proxy = self.http_proxy, | http_proxy = self.http_proxy, | ||||
| config = self.config) | config = self.config) | ||||
| p, attrs = parseSOAPRPC(r, attrs = 1) | p, attrs = parseSOAPRPC(r, attrs = 1) | ||||
| @@ -418,7 +418,7 @@ class SOAPProxy: | |||||
| count += 1 | count += 1 | ||||
| t = getattr(p, i) | t = getattr(p, i) | ||||
| if count == 1: # Only one piece of data, bubble it up | if count == 1: # Only one piece of data, bubble it up | ||||
| p = t | |||||
| p = t | |||||
| except: | except: | ||||
| pass | pass | ||||
| @@ -468,7 +468,7 @@ class SOAPProxy: | |||||
| return self.__f_call(*args, **kw) | return self.__f_call(*args, **kw) | ||||
| else: | else: | ||||
| return self.__r_call(*args, **kw) | return self.__r_call(*args, **kw) | ||||
| def __getattr__(self, name): | def __getattr__(self, name): | ||||
| if name == '__del__': | if name == '__del__': | ||||
| raise AttributeError, name | raise AttributeError, name | ||||
| @@ -32,11 +32,11 @@ | |||||
| # | # | ||||
| ################################################################################ | ################################################################################ | ||||
| """ | """ | ||||
| from __future__ import nested_scopes | |||||
| ident = '$Id: Types.py,v 1.19 2005/02/22 04:29:43 warnes Exp $' | ident = '$Id: Types.py,v 1.19 2005/02/22 04:29:43 warnes Exp $' | ||||
| from version import __version__ | from version import __version__ | ||||
| from __future__ import nested_scopes | |||||
| import UserList | import UserList | ||||
| import base64 | import base64 | ||||
| @@ -76,7 +76,7 @@ class anyType: | |||||
| else: | else: | ||||
| self._ns = self._validURIs[0] | self._ns = self._validURIs[0] | ||||
| self._name = name | self._name = name | ||||
| self._typed = typed | self._typed = typed | ||||
| self._attrs = {} | self._attrs = {} | ||||
| @@ -142,7 +142,7 @@ class anyType: | |||||
| value = unicode(value) | value = unicode(value) | ||||
| self._attrs[attr] = value | self._attrs[attr] = value | ||||
| def _setAttrs(self, attrs): | def _setAttrs(self, attrs): | ||||
| if type(attrs) in (ListType, TupleType): | if type(attrs) in (ListType, TupleType): | ||||
| @@ -1275,7 +1275,7 @@ class compoundType(anyType): | |||||
| retval[name] = getattr(self,name) | retval[name] = getattr(self,name) | ||||
| return retval | return retval | ||||
| def __getitem__(self, item): | def __getitem__(self, item): | ||||
| if type(item) == IntType: | if type(item) == IntType: | ||||
| return self.__dict__[self._keyord[item]] | return self.__dict__[self._keyord[item]] | ||||
| @@ -1300,7 +1300,7 @@ class compoundType(anyType): | |||||
| else: | else: | ||||
| self.__dict__[name] = value | self.__dict__[name] = value | ||||
| self._keyord.append(name) | self._keyord.append(name) | ||||
| def _placeItem(self, name, value, pos, subpos = 0, attrs = None): | def _placeItem(self, name, value, pos, subpos = 0, attrs = None): | ||||
| if subpos == 0 and type(self.__dict__[name]) != ListType: | if subpos == 0 and type(self.__dict__[name]) != ListType: | ||||
| @@ -1421,10 +1421,10 @@ class arrayType(UserList.UserList, compoundType): | |||||
| else: | else: | ||||
| retval = {} | retval = {} | ||||
| def fun(x): retval[str(x).encode(encoding)] = self.data[x] | def fun(x): retval[str(x).encode(encoding)] = self.data[x] | ||||
| map( fun, range(len(self.data)) ) | map( fun, range(len(self.data)) ) | ||||
| return retval | return retval | ||||
| def __getitem__(self, item): | def __getitem__(self, item): | ||||
| try: | try: | ||||
| return self.data[int(item)] | return self.data[int(item)] | ||||
| @@ -1589,7 +1589,7 @@ class faultType(structType, Error): | |||||
| __str__ = __repr__ | __str__ = __repr__ | ||||
| def __call__(self): | def __call__(self): | ||||
| return (self.faultcode, self.faultstring, self.detail) | |||||
| return (self.faultcode, self.faultstring, self.detail) | |||||
| class SOAPException(Exception): | class SOAPException(Exception): | ||||
| def __init__(self, code="", string="", detail=None): | def __init__(self, code="", string="", detail=None): | ||||
| @@ -1630,7 +1630,7 @@ class MethodFailed(Exception): | |||||
| def __str__(self): | def __str__(self): | ||||
| return repr(self.value) | return repr(self.value) | ||||
| ####### | ####### | ||||
| # Convert complex SOAPpy objects to native python equivalents | # 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, | This function recursively converts the passed 'container' object, | ||||
| and all public subobjects. (Private subobjects have names that | and all public subobjects. (Private subobjects have names that | ||||
| start with '_'.) | start with '_'.) | ||||
| Conversions: | Conversions: | ||||
| - faultType --> raise python exception | - faultType --> raise python exception | ||||
| - arrayType --> array | - arrayType --> array | ||||
| - compoundType --> dictionary | - compoundType --> dictionary | ||||
| """ | """ | ||||
| if level > 10: | if level > 10: | ||||
| return object | return object | ||||
| if isinstance( object, faultType ): | if isinstance( object, faultType ): | ||||
| if object.faultstring == "Required Header Misunderstood": | if object.faultstring == "Required Header Misunderstood": | ||||
| raise RequiredHeaderMismatch(object.detail) | raise RequiredHeaderMismatch(object.detail) | ||||
| @@ -1695,13 +1695,13 @@ def simplify_contents(object, level=0): | |||||
| This function recursively converts the sub-objects contained in a | This function recursively converts the sub-objects contained in a | ||||
| 'container' object to simple python types. | 'container' object to simple python types. | ||||
| Conversions: | Conversions: | ||||
| - faultType --> raise python exception | - faultType --> raise python exception | ||||
| - arrayType --> array | - arrayType --> array | ||||
| - compoundType --> dictionary | - compoundType --> dictionary | ||||
| """ | """ | ||||
| if level>10: return object | if level>10: return object | ||||
| if isinstance( object, faultType ): | if isinstance( object, faultType ): | ||||
| @@ -1709,7 +1709,7 @@ def simplify_contents(object, level=0): | |||||
| if isPublic(k): | if isPublic(k): | ||||
| setattr(object, k, simplify(object[k], level=level+1)) | setattr(object, k, simplify(object[k], level=level+1)) | ||||
| raise object | raise object | ||||
| elif isinstance( object, arrayType ): | |||||
| elif isinstance( object, arrayType ): | |||||
| data = object._aslist() | data = object._aslist() | ||||
| for k in range(len(data)): | for k in range(len(data)): | ||||
| object[k] = simplify(data[k], level=level+1) | object[k] = simplify(data[k], level=level+1) | ||||
| @@ -1730,7 +1730,7 @@ def simplify_contents(object, level=0): | |||||
| elif type(object)==list: | elif type(object)==list: | ||||
| for k in range(len(object)): | for k in range(len(object)): | ||||
| object[k] = simplify(object[k]) | object[k] = simplify(object[k]) | ||||
| return object | return object | ||||