diff piecrust/appconfig.py @ 853:f070a4fc033c

core: Continue PieCrust3 refactor, simplify pages. The asset pipeline is still the only function pipeline at this point. * No more `QualifiedPage`, and several other pieces of code deleted. * Data providers are simpler and more focused. For instance, the page iterator doesn't try to support other types of items. * Route parameters are proper known source metadata to remove the confusion between the two. * Make the baker and pipeline more correctly manage records and record histories. * Add support for record collapsing and deleting stale outputs in the asset pipeline.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 May 2017 00:06:59 -0700
parents 4850f8c21b6e
children 08e02c2a2a1a
line wrap: on
line diff
--- a/piecrust/appconfig.py	Wed May 17 00:11:48 2017 -0700
+++ b/piecrust/appconfig.py	Sun May 21 00:06:59 2017 -0700
@@ -386,7 +386,7 @@
         sc.setdefault('fs_endpoint', sn)
         sc.setdefault('ignore_missing_dir', False)
         sc.setdefault('data_endpoint', None)
-        sc.setdefault('data_type', 'iterator')
+        sc.setdefault('data_type', None)
         sc.setdefault('item_name', sn)
         sc.setdefault('items_per_page', 5)
         sc.setdefault('date_format', DEFAULT_DATE_FORMAT)
@@ -412,6 +412,8 @@
 
     # Check routes are referencing correct sources, have default
     # values, etc.
+    used_sources = set()
+    existing_sources = set(values['site']['sources'].keys())
     for rc in v:
         if not isinstance(rc, dict):
             raise ConfigurationError("All routes in 'site/routes' must be "
@@ -426,12 +428,14 @@
         r_source = rc.get('source')
         if r_source is None:
             raise ConfigurationError("Routes must specify a source.")
-        if (r_source and
-                r_source not in list(values['site']['sources'].keys())):
+        if r_source not in existing_sources:
             raise ConfigurationError("Route is referencing unknown "
                                      "source: %s" % r_source)
+        if r_source in used_sources:
+            raise ConfigurationError("Source '%s' already has a route." %
+                                     r_source)
+        used_sources.add(r_source)
 
-        rc.setdefault('pass', 0)
         rc.setdefault('page_suffix', '/%num%')
 
     return v