diff piecrust/app.py @ 39:2f717f961996

Better error reporting and cache validation. Fix the processor pipeline in the preview server. Move the `pages` route to first position.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 21 Aug 2014 22:28:22 -0700
parents 485682a6de50
children 2d617b889b00
line wrap: on
line diff
--- a/piecrust/app.py	Thu Aug 21 10:56:17 2014 -0700
+++ b/piecrust/app.py	Thu Aug 21 22:28:22 2014 -0700
@@ -24,7 +24,7 @@
 logger = logging.getLogger(__name__)
 
 
-CACHE_VERSION = 12
+CACHE_VERSION = 13
 
 
 class VariantNotFoundError(Exception):
@@ -68,6 +68,7 @@
 
             actual_cache_key = self._values.get('__cache_key')
             if actual_cache_key == cache_key:
+                self._values['__cache_valid'] = True
                 return
             logger.debug("Outdated cache key '%s' (expected '%s')." % (
                     actual_cache_key, cache_key))
@@ -92,6 +93,7 @@
         self._values['__cache_key'] = cache_key
         config_text = json.dumps(self._values)
         self.cache.write('config.json', config_text)
+        self._values['__cache_valid'] = False
 
     def _validateAll(self, values):
         # Put all the defaults in the `site` section.
@@ -181,6 +183,10 @@
             sitec['sources'] = sourcesc
 
             routesc = []
+            routesc.append({
+                    'url': '/%path:path%',
+                    'source': 'pages',
+                    'func': 'pcurl(path)'})
             sitec['routes'] = routesc
 
             taxonomiesc = {}
@@ -238,9 +244,6 @@
                         'taxonomy': 'categories',
                         'func': 'pccaturl(category)'})
 
-            routesc.append({'url': '/%path:path%', 'source': 'pages',
-                    'func': 'pcurl(path)'})
-
         # Validate sources/routes.
         sourcesc = sitec.get('sources')
         routesc = sitec.get('routes')