dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00170
[PATCH 4/7] Tweak server handler injection.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Now the server stores a default set of handlers rather than None if
none were passed in. Additionally, callers no longer have to copy
DEFAULT_HANDLERS; the copy is done in the TCPGitServer constructor, and
the dict is updated with any custom handlers.
Change-Id: If617630346bcb57074ec746d8e66d43ba1e00be5
---
NEWS | 2 ++
dulwich/server.py | 6 ++++--
dulwich/web.py | 6 ++++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index 4f826ca..d29171c 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,8 @@
* Change server capabilities methods to classmethods. (Dave Borowitz)
+ * Tweak server handler injection. (Dave Borowitz)
+
0.6.1 2010-07-22
diff --git a/dulwich/server.py b/dulwich/server.py
index 909b571..f4d3259 100644
--- a/dulwich/server.py
+++ b/dulwich/server.py
@@ -684,7 +684,7 @@ DEFAULT_HANDLERS = {
class TCPGitRequestHandler(SocketServer.StreamRequestHandler):
def __init__(self, handlers, *args, **kwargs):
- self.handlers = handlers and handlers or DEFAULT_HANDLERS
+ self.handlers = handlers
SocketServer.StreamRequestHandler.__init__(self, *args, **kwargs)
def handle(self):
@@ -708,8 +708,10 @@ class TCPGitServer(SocketServer.TCPServer):
return TCPGitRequestHandler(self.handlers, *args, **kwargs)
def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None):
+ self.handlers = dict(DEFAULT_HANDLERS)
+ if handlers is not None:
+ self.handlers.update(handlers)
self.backend = backend
- self.handlers = handlers
logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
SocketServer.TCPServer.__init__(self, (listen_addr, port),
self._make_handler)
diff --git a/dulwich/web.py b/dulwich/web.py
index 73aed6f..d7f845a 100644
--- a/dulwich/web.py
+++ b/dulwich/web.py
@@ -259,7 +259,7 @@ class HTTPGitRequest(object):
def __init__(self, environ, start_response, dumb=False, handlers=None):
self.environ = environ
self.dumb = dumb
- self.handlers = handlers and handlers or DEFAULT_HANDLERS
+ self.handlers = handlers
self._start_response = start_response
self._cache_headers = []
self._headers = []
@@ -340,7 +340,9 @@ class HTTPGitApplication(object):
def __init__(self, backend, dumb=False, handlers=None):
self.backend = backend
self.dumb = dumb
- self.handlers = handlers
+ self.handlers = dict(DEFAULT_HANDLERS)
+ if handlers is not None:
+ self.handlers.update(handlers)
def __call__(self, environ, start_response):
path = environ['PATH_INFO']
--
1.7.1
References