Permalink
Browse files

update source with 0.4.1 beta changes

  • Loading branch information...
1 parent 44b57ad commit 641b94ef3114f297b9e4d66327127c8b0b5e909b @htj committed Apr 19, 2012
Showing with 92 additions and 9 deletions.
  1. +4 −1 python-suds.spec
  2. +2 −2 suds/__init__.py
  3. +4 −3 suds/cache.py
  4. +60 −1 suds/client.py
  5. +6 −0 suds/options.py
  6. +1 −1 suds/sax/date.py
  7. +14 −0 tests/axis1.py
  8. +1 −1 tests/public.py
View
@@ -2,7 +2,7 @@
Summary: A python SOAP client
Name: python-suds
-Version: 0.4
+Version: 0.4.1
Release: 1%{?dist}
Source0: https://fedorahosted.org/releases/s/u/suds/%{name}-%{version}.tar.gz
License: LGPLv3+
@@ -54,6 +54,9 @@ rm -rf $RPM_BUILD_ROOT
%doc README LICENSE
%changelog
+* Thu Oct 15 2010 jortel <jortel@redhat.com> - 0.4.1-1
+- 0.4.1
+
* Thu Sep 8 2010 jortel <jortel@redhat.com> - 0.4-1
- Fix spelling errors in spec description.
- Fix source0 URL warning.
View
@@ -26,8 +26,8 @@
# Project properties
#
-__version__ = '0.4'
-__build__="GA R699-20100913"
+__version__ = '0.4.1'
+__build__="(beta) R705-20101207"
#
# Exceptions
View
@@ -244,11 +244,12 @@ def validate(self, fn):
def clear(self):
for fn in os.listdir(self.location):
- if os.path.isdir(fn):
+ path = os.path.join(self.location, fn)
+ if os.path.isdir(path):
continue
if fn.startswith(self.fnprefix):
- log.debug('deleted: %s', fn)
- os.remove(os.path.join(self.location, fn))
+ os.remove(path)
+ log.debug('deleted: %s', path)
def purge(self, id):
fn = self.__fn(id)
View
@@ -620,7 +620,9 @@ def send(self, soapenv):
binding = self.method.binding.input
transport = self.options.transport
retxml = self.options.retxml
+ nosend = self.options.nosend
prettyxml = self.options.prettyxml
+ timer = metrics.Timer()
log.debug('sending to (%s)\nmessage:\n%s', location, soapenv)
try:
self.last_sent(soapenv)
@@ -631,10 +633,16 @@ def send(self, soapenv):
else:
soapenv = soapenv.plain()
soapenv = soapenv.encode('utf-8')
- plugins.message.sending(envelope=soapenv)
+ ctx = plugins.message.sending(envelope=soapenv)
+ soapenv = ctx.envelope
+ if nosend:
+ return RequestContext(self, binding, soapenv)
request = Request(location, soapenv)
request.headers = self.headers()
+ timer.start()
reply = transport.send(request)
+ timer.stop()
+ metrics.log.debug('waited %s on server reply', timer)
ctx = plugins.message.received(reply=reply.message)
reply.message = ctx.reply
if retxml:
@@ -656,6 +664,8 @@ def headers(self):
@rtype: dict
"""
action = self.method.soap.action
+ if isinstance(action, unicode):
+ action = action.encode('utf-8')
stock = { 'Content-Type' : 'text/xml; charset=utf-8', 'SOAPAction': action }
result = dict(stock, **self.options.headers)
log.debug('headers = %s', result)
@@ -783,3 +793,52 @@ def __fault(self, reply):
return (500, p)
else:
return (500, None)
+
+
+class RequestContext:
+ """
+ A request context.
+ Returned when the ''nosend'' options is specified.
+ @ivar client: The suds client.
+ @type client: L{Client}
+ @ivar binding: The binding for this request.
+ @type binding: I{Binding}
+ @ivar envelope: The request soap envelope.
+ @type envelope: str
+ """
+
+ def __init__(self, client, binding, envelope):
+ """
+ @param client: The suds client.
+ @type client: L{Client}
+ @param binding: The binding for this request.
+ @type binding: I{Binding}
+ @param envelope: The request soap envelope.
+ @type envelope: str
+ """
+ self.client = client
+ self.binding = binding
+ self.envelope = envelope
+
+ def succeeded(self, reply):
+ """
+ Re-entry for processing a successful reply.
+ @param reply: The reply soap envelope.
+ @type reply: str
+ @return: The returned value for the invoked method.
+ @rtype: object
+ """
+ options = self.client.options
+ plugins = PluginContainer(options.plugins)
+ ctx = plugins.message.received(reply=reply)
+ reply = ctx.reply
+ return self.client.succeeded(self.binding, reply)
+
+ def failed(self, error):
+ """
+ Re-entry for processing a failure reply.
+ @param error: The error returned by the transport.
+ @type error: A suds I{TransportError}.
+ """
+ return self.client.failed(self.binding, error)
+
View
@@ -99,6 +99,11 @@ class Options(Skin):
- default: 0
- B{plugins} - A plugin container.
- type: I{list}
+ - B{nosend} - Create the soap envelope but don't send.
+ When specified, method invocation returns a I{RequestContext}
+ instead of sending it.
+ - type: I{bool}
+ - default: False
"""
def __init__(self, **kwargs):
domain = __name__
@@ -119,5 +124,6 @@ def __init__(self, **kwargs):
Definition('autoblend', bool, False),
Definition('cachingpolicy', int, 0),
Definition('plugins', (list, tuple), []),
+ Definition('nosend', bool, False),
]
Skin.__init__(self, domain, definitions, kwargs)
View
@@ -346,7 +346,7 @@ class Timezone:
pattern = re.compile('([zZ])|([\-\+][0-9]{2}:[0-9]{2})')
- LOCAL = ( 0-time.timezone/60/60 )
+ LOCAL = ( 0-time.timezone/60/60 ) + time.daylight
def __init__(self, offset=None):
if offset is None:
View
@@ -137,6 +137,20 @@ def start(url):
print 'addPersion()'
result = client.service.addPerson(person)
print '\nreply(\n%s\n)\n' % str(result)
+
+ #
+ # Async
+ #
+ client.options.nosend=True
+ 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>'
+ request = client.service.addPerson(person)
+ result = request.succeeded(reply)
+ error = Object()
+ error.httpcode = '500'
+ client.options.nosend=False
+# request.failed(error)
+
+ #
#
# create a new name object used to update the person
#
View
@@ -29,7 +29,7 @@
setup_logging()
#logging.getLogger('suds.client').setLevel(logging.DEBUG)
-#logging.getLogger('suds.metrics').setLevel(logging.DEBUG)
+logging.getLogger('suds.metrics').setLevel(logging.DEBUG)
#logging.getLogger('suds').setLevel(logging.DEBUG)

0 comments on commit 641b94e

Please sign in to comment.