Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Fix my previous SafeBasicAuthTransport refactoring.
Browse files Browse the repository at this point in the history
Tests are still missing for SSL transports.
  • Loading branch information
Adam Groszer committed Aug 30, 2010
1 parent f85b97f commit e79a850
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CHANGES
0.5.4 (unreleased)
------------------

- Nothing changed yet.
- Fix my previous SafeBasicAuthTransport refactoring.
Tests are still missing for SSL transports.


0.5.3 (2010-08-29)
Expand Down
11 changes: 7 additions & 4 deletions src/z3c/json/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def close(self):
self._target.feed(self.data)


class Transport:
class Transport(object):
"""Handles an HTTP transaction to an JSON-RPC server.
Standard transport class for JSON-RPC over HTTP.
Expand Down Expand Up @@ -201,7 +201,7 @@ def _parse_response(self, file, sock):
return u.close()


class SafeTransport(Transport):
class SafeTransportMixin(object):
"""Handles an HTTPS transaction to an JSON-RPC server."""

def make_connection(self, host):
Expand All @@ -220,8 +220,11 @@ def make_connection(self, host):
else:
return HTTPS(host, None, **(x509 or {}))

class SafeTransport(SafeTransportMixin, Transport):
"""Handles an HTTPS transaction to an JSON-RPC server."""

class BasicAuthTransport(Transport):
"""Handles a transaction to an JSON-RPC server using HTTP basic auth."""

def __init__(self, username=None, password=None, verbose=0):
self.username=username
Expand All @@ -235,7 +238,7 @@ def send_content(self, connection, request_body):
base64.encodestring("%s:%s" % (self.username, self.password)
).replace("\012", ""))

Transport.send_content(self, connection, request_body)
super(BasicAuthTransport, self).send_content(connection, request_body)

class SafeBasicAuthTransport(SafeTransport, BasicAuthTransport):
class SafeBasicAuthTransport(SafeTransportMixin, BasicAuthTransport):
"""Basic AUTH through HTTPS"""

0 comments on commit e79a850

Please sign in to comment.