diff decoupage/web.py @ 70:262fb90a54b4

make template loading lenient and other fixes; bump version
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 04 Aug 2012 15:55:52 -0700
parents 9fac58348520
children 12ee37017538
line wrap: on
line diff
--- a/decoupage/web.py	Fri Aug 03 23:48:25 2012 -0700
+++ b/decoupage/web.py	Sat Aug 04 15:55:52 2012 -0700
@@ -73,7 +73,7 @@
                 print >> sys.stderr, e
                 continue
             self.formats[_format.name] = _instance
-        
+
         # pluggable index data formatters
         self.formatters = {}
         for formatter in iter_entry_points('decoupage.formatters'):
@@ -86,17 +86,18 @@
                 # record the error, but persist
                 print >> sys.stderr, "Couldn't load formatter: %s" % formatter
                 print >> sts.stderr, e
-                continue 
+                continue
             self.formatters[formatter.name] = _formatter
-        
+
         # template loader
-        self.loader = TemplateLoader(self.template_directories, 
+        self.loader = TemplateLoader(self.template_directories,
+                                     variable_lookup="lenient",
                                      auto_reload=self.auto_reload)
 
-        
+
 
     ### methods dealing with HTTP
-        
+
     def __call__(self, environ, start_response):
 
         # boilerplate: request and filename
@@ -106,7 +107,7 @@
 
         # check to see what we have to serve
         if os.path.exists(path):
-            
+
             if os.path.isdir(path):
                 # serve an index
                 if request.path_info.endswith('/'):
@@ -129,7 +130,7 @@
                     fileserver = FileTypeTransformer(*args, **kwargs)
                 else:
                     fileserver = self.fileserver
-                    
+
                 fileserver = fileserver(path)
                 return fileserver(environ, start_response)
         else:
@@ -142,12 +143,12 @@
         """
         return response to a GET requst
         """
-        
-        # ensure a sane path        
+
+        # ensure a sane path
         path = request.path_info.strip('/')
         directory = os.path.join(self.directory, path)
         path = '/%s' % path
-        
+
         # get the configuraton
         conf = self.conf(path)
 
@@ -159,15 +160,10 @@
         # add a function to get the path to files
         data['filepath'] = lambda *segments: os.path.join(*([directory] + list(segments)))
 
-        # defaults; TODO: make this better
-        # there shouldn't need to be defaults;
-        # iirc, genshi has a mode where these will default to None
-        data['title'] = conf.get('/title')
+        # defaults
         data['directory'] = directory
-        data['include'] = None
         data['css'] = ()
         data['scripts'] = ()
-        data['icon'] = None
 
         # apply formatters
         # XXX this should be cached if not self.auto_reload