[Inteproxy-commits] r197 - in trunk: . inteproxy
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 10 22:09:32 CEST 2009
Author: bh
Date: 2009-09-10 22:09:32 +0200 (Thu, 10 Sep 2009)
New Revision: 197
Modified:
trunk/ChangeLog
trunk/create-rewrite-rules.py
trunk/inteproxy/transcoder.py
Log:
* inteproxy/transcoder.py
(TranscoderMap.add_rule, TranscoderMap.add_rules):
New. Replacements for add_host and add_hosts
(TranscoderMap.__init__): Rename instance variable hosts to rules.
(TranscoderMap.lookup, TranscoderMap.rewrite_urls)
(TranscoderMap.add_host): Adapt to instance variable change.
* create-rewrite-rules.py (read_transcoder_map),
inteproxy/main.py (run_server): Use the new TranscoderMap
functions
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-09-10 19:59:16 UTC (rev 196)
+++ trunk/ChangeLog 2009-09-10 20:09:32 UTC (rev 197)
@@ -1,5 +1,18 @@
2009-09-10 Bernhard Herzog <bh at intevation.de>
+ * inteproxy/transcoder.py
+ (TranscoderMap.add_rule, TranscoderMap.add_rules):
+ New. Replacements for add_host and add_hosts
+ (TranscoderMap.__init__): Rename instance variable hosts to rules.
+ (TranscoderMap.lookup, TranscoderMap.rewrite_urls)
+ (TranscoderMap.add_host): Adapt to instance variable change.
+
+ * create-rewrite-rules.py (read_transcoder_map),
+ inteproxy/main.py (run_server): Use the new TranscoderMap
+ functions
+
+2009-09-10 Bernhard Herzog <bh at intevation.de>
+
* inteproxy/config.py (read_config): Rename the config object's
hosts attribute to rules to better reflect its new contents
Modified: trunk/create-rewrite-rules.py
===================================================================
--- trunk/create-rewrite-rules.py 2009-09-10 19:59:16 UTC (rev 196)
+++ trunk/create-rewrite-rules.py 2009-09-10 20:09:32 UTC (rev 197)
@@ -61,7 +61,7 @@
transcoder_map.add_class("undefined", UndefinedTranscoder,
UndefinedTranscoder)
transcoder_map.set_default_class("undefined")
- transcoder_map.add_hosts(config.rules)
+ transcoder_map.add_rules(config.rules)
return transcoder_map
Modified: trunk/inteproxy/transcoder.py
===================================================================
--- trunk/inteproxy/transcoder.py 2009-09-10 19:59:16 UTC (rev 196)
+++ trunk/inteproxy/transcoder.py 2009-09-10 20:09:32 UTC (rev 197)
@@ -173,7 +173,7 @@
add_class method. The first item in classes will become the
default class.
"""
- self.hosts = []
+ self.rules = []
self.classmap = dict()
self.default_classname = None
@@ -199,7 +199,7 @@
A connection path on host will be done with the appropriate
transcoder from the class given by classname.
"""
- self.hosts.append((re.compile(pattern_to_regex(host,
+ self.rules.append((re.compile(pattern_to_regex(host,
character_set="[^/]")),
re.compile(pattern_to_regex(path)),
classname))
@@ -208,10 +208,23 @@
for entry in hosts:
self.add_host(entry.host, entry.path, entry.scheme)
+ def add_rule(self, rule):
+ """Adds a transcoder rule (typically an instance of InteProxyRule)
+ """
+ self.rules.append((re.compile(pattern_to_regex(rule.host,
+ character_set="[^/]")),
+ re.compile(pattern_to_regex(rule.path)),
+ rule.scheme))
+
+ def add_rules(self, rules):
+ """Adds all transcoder rules in rules"""
+ for rule in rules:
+ self.add_rule(rule)
+
def lookup(self, method, host, path):
"""Returns the python class implementing the transcoder for path on host
"""
- for host_regex, path_regex, classname in self.hosts:
+ for host_regex, path_regex, classname in self.rules:
host_match = host_regex.match(host)
if host_match and host_match.group(0) == host:
path_match = path_regex.match(path)
@@ -279,7 +292,7 @@
InteProxyHTTPRequestHandler.
"""
url_patterns = []
- for host_regex, path_regex, classname in self.hosts:
+ for host_regex, path_regex, classname in self.rules:
url_patterns.append("%s%s"
% (host_regex.pattern, path_regex.pattern))
regex = ("(?:http|https)://(?:"
More information about the Inteproxy-commits
mailing list