Package suds
[hide private]
[frames] | no frames]

Source Code for Package suds

  1  # This program is free software; you can redistribute it and/or modify 
  2  # it under the terms of the (LGPL) GNU Lesser General Public License as 
  3  # published by the Free Software Foundation; either version 3 of the  
  4  # License, or (at your option) any later version. 
  5  # 
  6  # This program is distributed in the hope that it will be useful, 
  7  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  8  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  9  # GNU Library Lesser General Public License for more details at 
 10  # ( http://www.gnu.org/licenses/lgpl.html ). 
 11  # 
 12  # You should have received a copy of the GNU Lesser General Public License 
 13  # along with this program; if not, write to the Free Software 
 14  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 15  # written by: Jeff Ortel ( jortel@redhat.com ) 
 16   
 17  """ 
 18  Suds is a lightweight SOAP python client that provides a 
 19  service proxy for Web Services. 
 20  """ 
 21   
 22  import os 
 23  import sys 
 24   
 25  # 
 26  # Project properties 
 27  # 
 28   
 29  __version__ = '0.4.1' 
 30  __build__="(beta) R705-20101207" 
 31   
 32  # 
 33  # Exceptions 
 34  # 
 35   
36 -class MethodNotFound(Exception):
37 - def __init__(self, name):
38 Exception.__init__(self, "Method not found: '%s'" % name)
39
40 -class PortNotFound(Exception):
41 - def __init__(self, name):
42 Exception.__init__(self, "Port not found: '%s'" % name)
43
44 -class ServiceNotFound(Exception):
45 - def __init__(self, name):
46 Exception.__init__(self, "Service not found: '%s'" % name)
47
48 -class TypeNotFound(Exception):
49 - def __init__(self, name):
50 Exception.__init__(self, "Type not found: '%s'" % tostr(name))
51
52 -class BuildError(Exception):
53 msg = \ 54 """ 55 An error occured while building a instance of (%s). As a result 56 the object you requested could not be constructed. It is recommended 57 that you construct the type manually using a Suds object. 58 Please open a ticket with a description of this error. 59 Reason: %s 60 """
61 - def __init__(self, name, exception):
62 Exception.__init__(self, BuildError.msg % (name, exception))
63
64 -class SoapHeadersNotPermitted(Exception):
65 msg = \ 66 """ 67 Method (%s) was invoked with SOAP headers. The WSDL does not 68 define SOAP headers for this method. Retry without the soapheaders 69 keyword argument. 70 """
71 - def __init__(self, name):
72 Exception.__init__(self, self.msg % name)
73
74 -class WebFault(Exception):
75 - def __init__(self, fault, document):
76 if hasattr(fault, 'faultstring'): 77 Exception.__init__(self, "Server raised fault: '%s'" % fault.faultstring) 78 self.fault = fault 79 self.document = document
80 81 # 82 # Logging 83 # 84
85 -class Repr:
86 - def __init__(self, x):
87 self.x = x
88 - def __str__(self):
89 return repr(self.x)
90 91 # 92 # Utility 93 # 94
95 -def tostr(object, encoding=None):
96 """ get a unicode safe string representation of an object """ 97 if isinstance(object, basestring): 98 if encoding is None: 99 return object 100 else: 101 return object.encode(encoding) 102 if isinstance(object, tuple): 103 s = ['('] 104 for item in object: 105 if isinstance(item, basestring): 106 s.append(item) 107 else: 108 s.append(tostr(item)) 109 s.append(', ') 110 s.append(')') 111 return ''.join(s) 112 if isinstance(object, list): 113 s = ['['] 114 for item in object: 115 if isinstance(item, basestring): 116 s.append(item) 117 else: 118 s.append(tostr(item)) 119 s.append(', ') 120 s.append(']') 121 return ''.join(s) 122 if isinstance(object, dict): 123 s = ['{'] 124 for item in object.items(): 125 if isinstance(item[0], basestring): 126 s.append(item[0]) 127 else: 128 s.append(tostr(item[0])) 129 s.append(' = ') 130 if isinstance(item[1], basestring): 131 s.append(item[1]) 132 else: 133 s.append(tostr(item[1])) 134 s.append(', ') 135 s.append('}') 136 return ''.join(s) 137 try: 138 return unicode(object) 139 except: 140 return str(object)
141
142 -class null:
143 """ 144 The I{null} object. 145 Used to pass NULL for optional XML nodes. 146 """ 147 pass
148
149 -def objid(obj):
150 return obj.__class__.__name__\ 151 +':'+hex(id(obj))
152 153 154 import client 155