2 ################################################################################
3 # Copyright (c) 2003, Pfizer
4 # Copyright (c) 2001, Cayce Ullman.
5 # Copyright (c) 2001, Brian Matthews.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
11 # Redistributions of source code must retain the above copyright notice, this
12 # list of conditions and the following disclaimer.
14 # Redistributions in binary form must reproduce the above copyright notice,
15 # this list of conditions and the following disclaimer in the documentation
16 # and/or other materials provided with the distribution.
18 # Neither the name of actzero, inc. nor the names of its contributors may
19 # be used to endorse or promote products derived from this software without
20 # specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
26 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ################################################################################
36 ident = '$Id: Config.py 1298 2006-11-07 00:54:15Z sanxiyn $'
37 from version import __version__
44 ################################################################################
46 ################################################################################
50 __readonly = ('SSLserver', 'SSLclient', 'GSIserver', 'GSIclient')
52 __slots__ = ('key_file', 'cert_file')
56 def __init__(self, config = None, **kw):
60 if not isinstance(config, SOAPConfig):
61 raise AttributeError, \
62 "initializer must be SOAPConfig instance"
66 for k, v in s.items():
70 # Setting debug also sets returnFaultInfo,
71 # dumpHeadersIn, dumpHeadersOut, dumpSOAPIn, and dumpSOAPOut
73 self.dumpFaultInfo = 1
74 # Setting namespaceStyle sets typesNamespace, typesNamespaceURI,
75 # schemaNamespace, and schemaNamespaceURI
76 self.namespaceStyle = '1999'
77 self.strictNamespaces = 0
79 self.buildWithNamespacePrefix = 1
80 self.returnAllAttrs = 0
82 # Strict checking of range for floats and doubles
85 # Default encoding for dictionary keys
86 self.dict_encoding = 'ascii'
88 # New argument name handling mechanism. See
89 # README.MethodParameterNaming for details
92 # If unwrap_results=1 and there is only element in the struct,
93 # SOAPProxy will assume that this element is the result
94 # and return it rather than the struct containing it.
95 # Otherwise SOAPproxy will return the struct with all the
96 # elements as attributes.
97 self.unwrap_results = 1
99 # Automatically convert SOAP complex types, and
100 # (recursively) public contents into the corresponding
101 # python types. (Private subobjects have names that start
105 # - faultType --> raise python exception
106 # - arrayType --> array
107 # - compoundType --> dictionary
109 self.simplify_objects = 0
111 # Per-class authorization method. If this is set, before
112 # calling a any class method, the specified authorization
113 # method will be called. If it returns 1, the method call
114 # will proceed, otherwise the call will throw with an
115 # authorization error.
116 self.authMethod = None
118 # Globus Support if pyGlobus.io available
120 from pyGlobus import io;
128 # Server SSL support if M2Crypto.SSL available
130 from M2Crypto import SSL
135 # Client SSL support if socket.ssl available
137 from socket import ssl
143 if d['SSLclient'] or d['SSLserver']:
144 d['SSL'] = self.SSLconfig()
146 for k, v in kw.items():
150 def __setattr__(self, name, value):
151 if name in self.__readonly:
152 raise AttributeError, "readonly configuration setting"
156 if name in ('typesNamespace', 'typesNamespaceURI',
157 'schemaNamespace', 'schemaNamespaceURI'):
159 if name[-3:] == 'URI':
160 base, uri = name[:-3], 1
164 if type(value) == StringType:
165 if NS.NSMAP.has_key(value):
166 n = (value, NS.NSMAP[value])
167 elif NS.NSMAP_R.has_key(value):
168 n = (NS.NSMAP_R[value], value)
170 raise AttributeError, "unknown namespace"
171 elif type(value) in (ListType, TupleType):
173 n = (value[1], value[0])
175 n = (value[0], value[1])
177 raise AttributeError, "unknown namespace type"
179 d[base], d[base + 'URI'] = n
182 d['namespaceStyle'] = \
183 NS.STMAP_R[(d['typesNamespace'], d['schemaNamespace'])]
185 d['namespaceStyle'] = ''
187 elif name == 'namespaceStyle':
190 if not NS.STMAP.has_key(value):
191 raise AttributeError, "unknown namespace style"
194 n = d['typesNamespace'] = NS.STMAP[value][0]
195 d['typesNamespaceURI'] = NS.NSMAP[n]
196 n = d['schemaNamespace'] = NS.STMAP[value][1]
197 d['schemaNamespaceURI'] = NS.NSMAP[n]
199 elif name == 'debug':
201 d['returnFaultInfo'] = \
202 d['dumpHeadersIn'] = \
203 d['dumpHeadersOut'] = \
205 d['dumpSOAPOut'] = value
211 Config = SOAPConfig()