changeset 26:f306089d6def

now use contenttransformer to serve files if /transformer in directory configuration; TODO: cache on a per-directory basis
author k0s <k0scist@gmail.com>
date Sun, 17 Jan 2010 19:49:04 -0500
parents d5775f3667a2
children 9e86c5cb111a 983c13e1b71f
files decoupage/web.py setup.py
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/web.py	Sat Jan 09 12:13:04 2010 -0500
+++ b/decoupage/web.py	Sun Jan 17 19:49:04 2010 -0500
@@ -4,6 +4,7 @@
 
 import os
 
+from contenttransformer.app import FileTypeTransformer
 from formatters import formatters
 
 from genshi.builder import Markup
@@ -60,6 +61,8 @@
         self.loader = TemplateLoader(self.template_directories, 
                                      auto_reload=self.auto_reload)
 
+        
+
     ### methods dealing with HTTP
     def __call__(self, environ, start_response):
         request = Request(environ)
@@ -74,7 +77,14 @@
                 res = self.get(request)
                 return res(environ, start_response)
             else:
-                fileserver = self.fileserver(path)
+                conf = self.conf(request.path_info.rsplit('/',1)[0])
+                if '/transformer' in conf:
+                    args = [i.split('=', 1) for i in conf['/transformer'].split(',') if '=' in i]
+                    fileserver = FileTypeTransformer(*args)
+                else:
+                    fileserver = FileApp
+                    
+                fileserver = fileserver(path)
                 return fileserver(environ, start_response)
         else:
             raise exc.HTTPNotFound()
@@ -197,7 +207,7 @@
             parent_configuration = self.conf(inherit_directory)
             for key, value in parent_configuration.items():
                 if key.startswith('/') and key not in conf:
-                    conf[key] = value
+                    conf[key] = value                
 
         # cache configuration
         if not self.auto_reload:
--- a/setup.py	Sat Jan 09 12:13:04 2010 -0500
+++ b/setup.py	Sun Jan 17 19:49:04 2010 -0500
@@ -6,7 +6,7 @@
 except IOError:
     description = ''
 
-version = '0.4.2'
+version = '0.5'
 
 setup(name='decoupage',
       version=version,
@@ -27,6 +27,7 @@
          'PasteScript',
          'genshi',
          'martINI',
+         'contenttransformer',
          ],
       entry_points="""
       # -*- Entry points: -*-