Skip to content

Commit 641b94e

Browse files
author
Henrik Thostrup Jensen
committed
update source with 0.4.1 beta changes
1 parent 44b57ad commit 641b94e

File tree

8 files changed

+92
-9
lines changed

8 files changed

+92
-9
lines changed

python-suds.spec

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Summary: A python SOAP client
44
Name: python-suds
5-
Version: 0.4
5+
Version: 0.4.1
66
Release: 1%{?dist}
77
Source0: https://fedorahosted.org/releases/s/u/suds/%{name}-%{version}.tar.gz
88
License: LGPLv3+
@@ -54,6 +54,9 @@ rm -rf $RPM_BUILD_ROOT
5454
%doc README LICENSE
5555

5656
%changelog
57+
* Thu Oct 15 2010 jortel <jortel@redhat.com> - 0.4.1-1
58+
- 0.4.1
59+
5760
* Thu Sep 8 2010 jortel <jortel@redhat.com> - 0.4-1
5861
- Fix spelling errors in spec description.
5962
- Fix source0 URL warning.

suds/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
# Project properties
2727
#
2828

29-
__version__ = '0.4'
30-
__build__="GA R699-20100913"
29+
__version__ = '0.4.1'
30+
__build__="(beta) R705-20101207"
3131

3232
#
3333
# Exceptions

suds/cache.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ def validate(self, fn):
244244

245245
def clear(self):
246246
for fn in os.listdir(self.location):
247-
if os.path.isdir(fn):
247+
path = os.path.join(self.location, fn)
248+
if os.path.isdir(path):
248249
continue
249250
if fn.startswith(self.fnprefix):
250-
log.debug('deleted: %s', fn)
251-
os.remove(os.path.join(self.location, fn))
251+
os.remove(path)
252+
log.debug('deleted: %s', path)
252253

253254
def purge(self, id):
254255
fn = self.__fn(id)

suds/client.py

+60-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,9 @@ def send(self, soapenv):
620620
binding = self.method.binding.input
621621
transport = self.options.transport
622622
retxml = self.options.retxml
623+
nosend = self.options.nosend
623624
prettyxml = self.options.prettyxml
625+
timer = metrics.Timer()
624626
log.debug('sending to (%s)\nmessage:\n%s', location, soapenv)
625627
try:
626628
self.last_sent(soapenv)
@@ -631,10 +633,16 @@ def send(self, soapenv):
631633
else:
632634
soapenv = soapenv.plain()
633635
soapenv = soapenv.encode('utf-8')
634-
plugins.message.sending(envelope=soapenv)
636+
ctx = plugins.message.sending(envelope=soapenv)
637+
soapenv = ctx.envelope
638+
if nosend:
639+
return RequestContext(self, binding, soapenv)
635640
request = Request(location, soapenv)
636641
request.headers = self.headers()
642+
timer.start()
637643
reply = transport.send(request)
644+
timer.stop()
645+
metrics.log.debug('waited %s on server reply', timer)
638646
ctx = plugins.message.received(reply=reply.message)
639647
reply.message = ctx.reply
640648
if retxml:
@@ -656,6 +664,8 @@ def headers(self):
656664
@rtype: dict
657665
"""
658666
action = self.method.soap.action
667+
if isinstance(action, unicode):
668+
action = action.encode('utf-8')
659669
stock = { 'Content-Type' : 'text/xml; charset=utf-8', 'SOAPAction': action }
660670
result = dict(stock, **self.options.headers)
661671
log.debug('headers = %s', result)
@@ -783,3 +793,52 @@ def __fault(self, reply):
783793
return (500, p)
784794
else:
785795
return (500, None)
796+
797+
798+
class RequestContext:
799+
"""
800+
A request context.
801+
Returned when the ''nosend'' options is specified.
802+
@ivar client: The suds client.
803+
@type client: L{Client}
804+
@ivar binding: The binding for this request.
805+
@type binding: I{Binding}
806+
@ivar envelope: The request soap envelope.
807+
@type envelope: str
808+
"""
809+
810+
def __init__(self, client, binding, envelope):
811+
"""
812+
@param client: The suds client.
813+
@type client: L{Client}
814+
@param binding: The binding for this request.
815+
@type binding: I{Binding}
816+
@param envelope: The request soap envelope.
817+
@type envelope: str
818+
"""
819+
self.client = client
820+
self.binding = binding
821+
self.envelope = envelope
822+
823+
def succeeded(self, reply):
824+
"""
825+
Re-entry for processing a successful reply.
826+
@param reply: The reply soap envelope.
827+
@type reply: str
828+
@return: The returned value for the invoked method.
829+
@rtype: object
830+
"""
831+
options = self.client.options
832+
plugins = PluginContainer(options.plugins)
833+
ctx = plugins.message.received(reply=reply)
834+
reply = ctx.reply
835+
return self.client.succeeded(self.binding, reply)
836+
837+
def failed(self, error):
838+
"""
839+
Re-entry for processing a failure reply.
840+
@param error: The error returned by the transport.
841+
@type error: A suds I{TransportError}.
842+
"""
843+
return self.client.failed(self.binding, error)
844+

suds/options.py

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ class Options(Skin):
9999
- default: 0
100100
- B{plugins} - A plugin container.
101101
- type: I{list}
102+
- B{nosend} - Create the soap envelope but don't send.
103+
When specified, method invocation returns a I{RequestContext}
104+
instead of sending it.
105+
- type: I{bool}
106+
- default: False
102107
"""
103108
def __init__(self, **kwargs):
104109
domain = __name__
@@ -119,5 +124,6 @@ def __init__(self, **kwargs):
119124
Definition('autoblend', bool, False),
120125
Definition('cachingpolicy', int, 0),
121126
Definition('plugins', (list, tuple), []),
127+
Definition('nosend', bool, False),
122128
]
123129
Skin.__init__(self, domain, definitions, kwargs)

suds/sax/date.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class Timezone:
346346

347347
pattern = re.compile('([zZ])|([\-\+][0-9]{2}:[0-9]{2})')
348348

349-
LOCAL = ( 0-time.timezone/60/60 )
349+
LOCAL = ( 0-time.timezone/60/60 ) + time.daylight
350350

351351
def __init__(self, offset=None):
352352
if offset is None:

tests/axis1.py

+14
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ def start(url):
137137
print 'addPersion()'
138138
result = client.service.addPerson(person)
139139
print '\nreply(\n%s\n)\n' % str(result)
140+
141+
#
142+
# Async
143+
#
144+
client.options.nosend=True
145+
reply = '<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:addPersonResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://basic.suds.fedora.org"><addPersonReturn xsi:type="xsd:string">person (jeff&#x4D2;,ortel) at age 43 with phone numbers (410-555-5138,919-555-4406,205-777-1212, and pets (Chance,) - added.</addPersonReturn></ns1:addPersonResponse></soapenv:Body></soapenv:Envelope>'
146+
request = client.service.addPerson(person)
147+
result = request.succeeded(reply)
148+
error = Object()
149+
error.httpcode = '500'
150+
client.options.nosend=False
151+
# request.failed(error)
152+
153+
#
140154
#
141155
# create a new name object used to update the person
142156
#

tests/public.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
setup_logging()
3030

3131
#logging.getLogger('suds.client').setLevel(logging.DEBUG)
32-
#logging.getLogger('suds.metrics').setLevel(logging.DEBUG)
32+
logging.getLogger('suds.metrics').setLevel(logging.DEBUG)
3333
#logging.getLogger('suds').setLevel(logging.DEBUG)
3434

3535

0 commit comments

Comments
 (0)