[z3-checkins] r44249 - in z3/deliverance/DeliveranceVHoster/trunk: . dvhoster

ltucker at codespeak.net ltucker at codespeak.net
Thu Jun 14 23:01:26 CEST 2007


Author: ltucker
Date: Thu Jun 14 23:01:24 2007
New Revision: 44249

Modified:
   z3/deliverance/DeliveranceVHoster/trunk/development.ini
   z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py
   z3/deliverance/DeliveranceVHoster/trunk/setup.py
Log:
add transcluder to the vhoster stack

Modified: z3/deliverance/DeliveranceVHoster/trunk/development.ini
==============================================================================
--- z3/deliverance/DeliveranceVHoster/trunk/development.ini	(original)
+++ z3/deliverance/DeliveranceVHoster/trunk/development.ini	Thu Jun 14 23:01:24 2007
@@ -51,4 +51,19 @@
 default_theme_uri = http://www.openplans.org
 domain_regex = ^(.*)\.flow\.openplans\.org$
 
+# transluder configuration
+
+# transcluder_ok_hosts controls which hosts 
+# transcluder will include and recursively 
+# transclude from. 
+# 
+# this can be: 
+# all - any host is ok
+# none - no hosts are ok 
+# localhost - only localhsost 
+# <regex> - only hosts matching the regex given
+#
+transcluder_ok_hosts = openplans.org|(.*)\.openplans.org|(.*)\.localhost.openplans\.org|localhost
+transcluder_pool_size = 0
+
 ### END THIS IMPORTANT STUFF ###

Modified: z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py
==============================================================================
--- z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py	(original)
+++ z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py	Thu Jun 14 23:01:24 2007
@@ -17,6 +17,9 @@
 from dvhoster.logcreate import make_logger
 from dvhoster import uritemplate
 
+import transcluder
+from transcluder.middleware import TranscluderMiddleware
+
 def norm_path(urlpath):
     if not urlpath:
         urlpath = '/'
@@ -63,6 +66,28 @@
         logger = make_logger(app_conf.get('logger'), 'dvhoster')
         self.logger = logger
 
+        # transcluder configuration 
+        ok_hosts = app_conf.get('transcluder_ok_hosts')
+
+        if not ok_hosts or ok_hosts == 'all':
+            self.transcluder_ok_hosts = transcluder.helpers.all_urls
+        elif ok_hosts == 'none':
+            self.transcluder_ok_hosts = transcluder.helpers.no_urls
+        elif ok_hosts == 'localhost':
+            self.transcluder_ok_hosts = transcluder.helpers.localhost_only
+        else:
+            self.transcluder_ok_hosts = transcluder.helpers.make_regex_predicate(ok_hosts)
+
+        self.transcluder_deptracker = transcluder.deptracker.DependencyTracker()
+
+        poolsize = 0
+        try:
+            poolsize = int(app_conf.get('transcluder_pool_size'))
+        except:
+            pass
+        
+        self.transcluder_pool = transcluder.tasklist.TaskList(poolsize=poolsize)
+            
     def __call__(self, environ, start_response):
         """
         WSGI interface
@@ -140,6 +165,12 @@
             remote=remote_uri,
             force_host=True)
 
+        app = TranscluderMiddleware(app,
+                                    deptracker=self.transcluder_deptracker,
+                                    tasklist=self.transcluder_pool,
+                                    include_predicate=self.transcluder_ok_hosts,
+                                    recursion_predicate=self.transcluder_ok_hosts)
+        
         if should_theme_uri:
             if self.rewrite_links:
                 app = relocateresponse.RelocateMiddleware(

Modified: z3/deliverance/DeliveranceVHoster/trunk/setup.py
==============================================================================
--- z3/deliverance/DeliveranceVHoster/trunk/setup.py	(original)
+++ z3/deliverance/DeliveranceVHoster/trunk/setup.py	Thu Jun 14 23:01:24 2007
@@ -15,10 +15,12 @@
       'HTTPEncode',
       'OHM==dev,>0.1',
       'wsgi_intercept',
+      'Transcluder'
       ],
     dependency_links=[
       'http://codespeak.net/svn/z3/deliverance/trunk#egg=Deliverance-dev',
       'http://darcs.idyll.org/~t/projects/wsgi_intercept/wsgi_intercept.py#egg=wsgi_intercept-dev',
+      'http://svn.openplans.org/svn/transcluder/trunk#egg=Trancluder-dev'
     ],
     packages=find_packages(),
     include_package_data=True,


More information about the z3-checkins mailing list