diff decoupage/web.py @ 10:a328cc9d2c74

* fix formatters * allow /inherit keyword to specify configuration * bump version
author k0s <k0scist@gmail.com>
date Fri, 25 Dec 2009 01:03:06 -0500
parents 6a802c87f070
children 9f91acf9874c
line wrap: on
line diff
--- a/decoupage/web.py	Thu Dec 24 23:33:37 2009 -0500
+++ b/decoupage/web.py	Fri Dec 25 01:03:06 2009 -0500
@@ -4,6 +4,8 @@
 
 import os
 
+from formatters import formatters
+
 from genshi.builder import Markup
 from genshi.template import TemplateLoader
 from martini.config import ConfigMunger
@@ -99,7 +101,6 @@
             files.append({'path' : '%s/%s' % (path.rstrip('/'), i),
                           'name': i,
                           'description': conf.get(i.lower(), None)})
-
         # build data dictionary
         data = {'path': path, 'files': files, 'request': request}
 
@@ -119,7 +120,8 @@
         for name in formatters:
             formatter = self.formatters[name](conf.get('/%s' % name, ''))
             formatter(request, data)
-        
+
+
         # render the template
         template = conf.get('/template')
         if template is None:
@@ -137,8 +139,10 @@
 
     ### internal methods
 
-    def conf(self, path):
+    def conf(self, path, cascade=None):
         """returns configuration dictionary appropriate to a path"""
+        if cascade is None:
+            cascase = self.cascade
 
         directory = os.path.join(self.directory, path.strip('/'))
         if path.strip('/'):
@@ -163,9 +167,14 @@
         if not conf and self.configuration and os.path.exists(self.configuration):
             conf = ConfigMunger(self.configuration).dict().get('/%s' % path.rstrip('/'), {})
 
-        # cascade configuration
-        if self.cascade and path_tuple:
-            parent_configuration = self.conf('/%s' % '/'.join(path_tuple[:-1]))
+        # inherit and cascade configuration
+        inherit_directory = None
+        if '/inherit' in conf:
+            inherit_directory = conf['/inherit']
+        elif self.cascade and path_tuple:
+            inherit_directory = '/%s' % '/'.join(path_tuple[:-1])
+        if inherit_directory:
+            parent_configuration = self.conf(inherit_directory)
             for key, value in parent_configuration.items():
                 if key.startswith('/') and key not in conf:
                     conf[key] = value