Browse Source

fix compat with python 3.5

main
jordism 8 years ago
parent
commit
31aeb5239c
7 changed files with 112 additions and 17 deletions
  1. +95
    -2
      src/SOAPpy/Client.py
  2. +2
    -2
      src/SOAPpy/Config.py
  3. +4
    -2
      src/SOAPpy/Errors.py
  4. +1
    -1
      src/SOAPpy/Parser.py
  5. +1
    -1
      src/SOAPpy/SOAPBuilder.py
  6. +1
    -1
      src/SOAPpy/Server.py
  7. +8
    -8
      src/SOAPpy/__init__.py

+ 95
- 2
src/SOAPpy/Client.py View File

@@ -52,7 +52,7 @@ from .types import *
import re import re
import base64 import base64
import socket, http.client import socket, http.client
from http.client import HTTPConnection, HTTP
from http.client import HTTPConnection
import http.cookies import http.cookies


# SOAPpy modules # SOAPpy modules
@@ -61,7 +61,8 @@ from .Config import Config
from .Parser import parseSOAPRPC from .Parser import parseSOAPRPC
from .SOAPBuilder import buildSOAP from .SOAPBuilder import buildSOAP
from .Utilities import * from .Utilities import *
from .Types import faultType, simplify
from .types import faultType, simplify

import collections import collections


################################################################################ ################################################################################
@@ -73,6 +74,98 @@ def SOAPUserAgent():
return "SOAPpy " + __version__ + " (pywebsvcs.sf.net)" return "SOAPpy " + __version__ + " (pywebsvcs.sf.net)"




class HTTP:
"Compatibility class with httplib.py from 1.5."

_http_vsn = 10
_http_vsn_str = 'HTTP/1.0'

debuglevel = 0

_connection_class = HTTPConnection

def __init__(self, host='', port=None, strict=None):
"Provide a default host, since the superclass requires one."

# some joker passed 0 explicitly, meaning default port
if port == 0:
port = None

# Note that we may pass an empty string as the host; this will raise
# an error when we attempt to connect. Presumably, the client code
# will call connect before then, with a proper host.
self._setup(self._connection_class(host, port, strict))

def _setup(self, conn):
self._conn = conn

# set up delegation to flesh out interface
self.send = conn.send
self.putrequest = conn.putrequest
self.putheader = conn.putheader
self.endheaders = conn.endheaders
self.set_debuglevel = conn.set_debuglevel

conn._http_vsn = self._http_vsn
conn._http_vsn_str = self._http_vsn_str

self.file = None

def connect(self, host=None, port=None):
"Accept arguments to set the host/port, since the superclass doesn't."

if host is not None:
(self._conn.host, self._conn.port) = self._conn._get_hostport(host, port)
self._conn.connect()

def getfile(self):
"Provide a getfile, since the superclass' does not use this concept."
return self.file

def getreply(self, buffering=False):
"""Compat definition since superclass does not define it.

Returns a tuple consisting of:
- server status code (e.g. '200' if all goes well)
- server "reason" corresponding to status code
- any RFC822 headers in the response from the server
"""
try:
if not buffering:
response = self._conn.getresponse()
else:
#only add this keyword if non-default for compatibility
#with other connection classes
response = self._conn.getresponse(buffering)
except BadStatusLine as e:
### hmm. if getresponse() ever closes the socket on a bad request,
### then we are going to have problems with self.sock

### should we keep this behavior? do people use it?
# keep the socket open (as a file), and return it
self.file = self._conn.sock.makefile('rb', 0)

# close our socket -- we want to restart after any protocol error
self.close()

self.headers = None
return -1, e.line, None

self.headers = response.msg
self.file = response.fp
return response.status, response.reason, response.msg

def close(self):
self._conn.close()

# note that self.file == response.fp, which gets closed by the
# superclass. just clear the object ref here.
### hmm. messy. if status==-1, then self.file is owned by us.
### well... we aren't explicitly closing, but losing this ref will
### do it
self.file = None


class SOAPAddress: class SOAPAddress:
def __init__(self, url, config = Config): def __init__(self, url, config = Config):
proto, uri = urllib.parse.splittype(url) proto, uri = urllib.parse.splittype(url)


+ 2
- 2
src/SOAPpy/Config.py View File

@@ -50,10 +50,10 @@ class SOAPConfig:
__readonly = ('SSLserver', 'SSLclient', 'GSIserver', 'GSIclient') __readonly = ('SSLserver', 'SSLclient', 'GSIserver', 'GSIclient')
class SSLconfig: class SSLconfig:
__slots__ = ('key_file', 'cert_file') __slots__ = ('key_file', 'cert_file')
key_file = None
cert_file = None


def __init__(self, config = None, **kw): def __init__(self, config = None, **kw):
self.key_file = None
self.cert_file = None
d = self.__dict__ d = self.__dict__


if config: if config:


+ 4
- 2
src/SOAPpy/Errors.py View File

@@ -42,8 +42,10 @@


ident = '$Id: Errors.py 921 2005-02-15 16:32:23Z warnes $' ident = '$Id: Errors.py 921 2005-02-15 16:32:23Z warnes $'
from .version import __version__ from .version import __version__

import exceptions
try:
import exceptions
except ImportError:
import builtins as exceptions


################################################################################ ################################################################################
# Exceptions # Exceptions


+ 1
- 1
src/SOAPpy/Parser.py View File

@@ -1,7 +1,7 @@
# SOAPpy modules # SOAPpy modules
import traceback import traceback
from .Config import Config from .Config import Config
from .Types import *
from .types import *
from .NS import NS from .NS import NS
from .Utilities import * from .Utilities import *




+ 1
- 1
src/SOAPpy/SOAPBuilder.py View File

@@ -42,7 +42,7 @@ from wstools.XMLname import toXMLname, fromXMLname
# SOAPpy modules # SOAPpy modules
from .Config import Config from .Config import Config
from .NS import NS from .NS import NS
from .Types import *
from .types import *


# Test whether this Python version has Types.BooleanType # Test whether this Python version has Types.BooleanType
# If it doesn't have it, then False and True are serialized as integers # If it doesn't have it, then False and True are serialized as integers


+ 1
- 1
src/SOAPpy/Server.py View File

@@ -56,7 +56,7 @@ import _thread
# SOAPpy modules # SOAPpy modules
from .Parser import parseSOAPRPC from .Parser import parseSOAPRPC
from .Config import Config from .Config import Config
from .Types import faultType, voidType, simplify
from .types import faultType, voidType, simplify
from .NS import NS from .NS import NS
from .SOAPBuilder import buildSOAP from .SOAPBuilder import buildSOAP
from .Utilities import debugHeader, debugFooter from .Utilities import debugHeader, debugFooter


+ 8
- 8
src/SOAPpy/__init__.py View File

@@ -2,14 +2,14 @@
ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $' ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $'
from .version import __version__ from .version import __version__


from .Client import *
from .Config import *
from .Errors import *
from .NS import *
from .Parser import *
from .Client import *
from .Config import *
from .Errors import *
from .NS import *
from .Parser import *
from .SOAPBuilder import * from .SOAPBuilder import *
from .Server import *
from .Types import *
from .Utilities import *
from .Server import *
from .types import *
from .Utilities import *
import wstools import wstools
from . import WSDL from . import WSDL

Loading…
Cancel
Save