[Inteproxy-commits] r38 - trunk
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 5 20:25:12 CEST 2007
Author: bh
Date: 2007-04-05 20:25:12 +0200 (Thu, 05 Apr 2007)
New Revision: 38
Modified:
trunk/ChangeLog
trunk/transcoder.py
Log:
* transcoder.py (TranscoderMap): Add a doc-string
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-04-05 18:10:28 UTC (rev 37)
+++ trunk/ChangeLog 2007-04-05 18:25:12 UTC (rev 38)
@@ -1,5 +1,9 @@
2007-04-05 Bernhard Herzog <bh at intevation.de>
+ * transcoder.py (TranscoderMap): Add a doc-string
+
+2007-04-05 Bernhard Herzog <bh at intevation.de>
+
* test/test_transcoder_map.py: New. Test cases for the TranscoderMap
* test/support.py: New. Support code for test cases
Modified: trunk/transcoder.py
===================================================================
--- trunk/transcoder.py 2007-04-05 18:10:28 UTC (rev 37)
+++ trunk/transcoder.py 2007-04-05 18:25:12 UTC (rev 38)
@@ -118,7 +118,16 @@
class TranscoderMap(object):
+ """Manages the host specific transcoder settings"""
+
def __init__(self, classes):
+ """Initializes the TranscoderMap.
+
+ The parameter 'classes' should be a sequence of (name, get,
+ post) triples. They will be used to add classes with the
+ add_class method. The first item in classes will become the
+ default class.
+ """
self.hostmap = dict()
self.classmap = dict()
self.default_classname = None
@@ -129,19 +138,32 @@
self.set_default_class(classes[0][0])
def set_default_class(self, name):
+ """Sets the default class"""
self.default_classname = name
def add_class(self, name, get, post):
+ """Adds a transcoder class named name.
+ The get and post parameters are the python classes implementing
+ the transcoder for the GET and POST methods.
+ """
self.classmap[name] = dict(GET=get, POST=post)
def add_host(self, host, path, classname):
+ """Adds a host description.
+
+ A connection path on host will be done with the appropriate
+ transcoder from the class given by classname.
+ """
self.hostmap[(host, path)] = classname
def lookup(self, method, host, path):
+ """Returns the python class implementing the transcoder for path on host
+ """
classname = self.hostmap.get((host, path), self.default_classname)
return self.classmap[classname][method]
def read_config(self, filename):
+ """Reads a configuration file and adds the host descriptions found"""
parser = SafeConfigParser()
parser.read([filename])
for section in parser.sections():
More information about the Inteproxy-commits
mailing list