[Erp5-report] r41432 luke - in /erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache:...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 14 18:18:22 CET 2010


Author: luke
Date: Tue Dec 14 18:18:21 2010
New Revision: 41432

URL: http://svn.erp5.org?rev=41432&view=rev
Log:
 - add support for more dynamic configuration of zope virtual host
   monster

Added:
    erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.path.in
Modified:
    erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/__init__.py
    erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.in

Modified: erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/__init__.py?rev=41432&r1=41431&r2=41432&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/__init__.py [utf8] Tue Dec 14 18:18:21 2010
@@ -106,13 +106,45 @@ class Apache:
 
 class Zope(Apache):
   """Apache instance to serve Zope backend"""
+  rewrite_rule = "RewriteRule %(path)s($|/.*) http://%(backend_ip)s:%(backend_port)s/VirtualHostBase/https/%%{SERVER_NAME}:%(port)s/%(backend_path)s/VirtualHostRoot/_vh_%(vhname)s$1 [L,P]"
+  top_rewrite_rule = "RewriteRule (.*) http://%(backend_ip)s:%(backend_port)s/VirtualHostBase/https/%%{SERVER_NAME}:%(port)s$1 [L,P]"
+
   def __init__(self, buildout, name, options):
     Apache.__init__(self, buildout, name, options)
-    for k in 'backend_ip', 'backend_port', 'backend_path':
-      self.options[k] = self.options[k].strip()
 
   def install(self):
     Apache.install(self)
+    path_template = pkg_resources.resource_string(__name__,
+      'templates/zope.conf.path.in')
+    path_list = []
+    rewrite_list = []
+    last_rewrite = None
+    for line in self.options['backend_mapping'].split('\n'):
+      line = line.strip()
+      if len(line) == 0:
+        continue
+      backend, path = line.split()
+      path_list.append(path_template % dict(path=path))
+      backend_ip, backend_port_path = backend.split(':')
+      backend_port, backend_path = backend_port_path.split('/',1)
+      d = dict(
+          path=path,
+          backend_ip=backend_ip,
+          backend_port=backend_port,
+          backend_path=backend_path,
+          port=self.options['port'],
+          vhname=path.replace('/',''),
+        )
+      if path == '/':
+        last_rewrite = self.top_rewrite_rule % d
+      else:
+        rewrite_list.append(self.rewrite_rule % d)
+    if last_rewrite is not None:
+      rewrite_list.append(last_rewrite)
+    self.options.update(**dict(
+      path_enable='\n'.join(path_list),
+      rewrite_rule='\n'.join(rewrite_list)
+    ))
     open(self.options['config_file'], 'w').write(pkg_resources.resource_string(
       __name__, 'templates/zope.conf.in') % self.options)
     open(self.options['running_wrapper'], 'w').write("""#!/bin/sh

Modified: erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.in
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.in?rev=41432&r1=41431&r2=41432&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.in [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.in [utf8] Tue Dec 14 18:18:21 2010
@@ -34,19 +34,14 @@ CustomLog "%(access_log)s" common
     Deny from all
 </Directory>
 
-# Path enabled
-<Location /%(path)s>
-  Order Deny,Allow
-  Deny from all
-  Allow from all
-</Location>
+%(path_enable)s
 
 # Magic of Zope related rewrite
 RewriteEngine On
 RewriteCond %%{SERVER_NAME} !%(regex_server_name)s
 RewriteRule . - [F,L]
 RewriteCond %%{SERVER_NAME} %(regex_server_name)s
-RewriteRule /%(path)s($|/.*) http://%(backend_ip)s:%(backend_port)s/VirtualHostBase/https/%%{SERVER_NAME}:%(port)s/%(backend_path)s/VirtualHostRoot/_vh_%(path)s$1 [L,P]
+%(rewrite_rule)s
 
 # List of module
 LoadModule authz_host_module modules/mod_authz_host.so

Added: erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.path.in
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.path.in?rev=41432&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.path.in (added)
+++ erp5/trunk/utils/erp5.recipe.apache/src/erp5/recipe/apache/templates/zope.conf.path.in [utf8] Tue Dec 14 18:18:21 2010
@@ -0,0 +1,5 @@
+# Path enabled
+<Location %(path)s>
+  Order Allow,Deny
+  Allow from all
+</Location>



More information about the Erp5-report mailing list