comparison 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
comparison
equal deleted inserted replaced
852:4850f8c21b6e 853:f070a4fc033c
384 "be dictionaries.") 384 "be dictionaries.")
385 sc.setdefault('type', 'default') 385 sc.setdefault('type', 'default')
386 sc.setdefault('fs_endpoint', sn) 386 sc.setdefault('fs_endpoint', sn)
387 sc.setdefault('ignore_missing_dir', False) 387 sc.setdefault('ignore_missing_dir', False)
388 sc.setdefault('data_endpoint', None) 388 sc.setdefault('data_endpoint', None)
389 sc.setdefault('data_type', 'iterator') 389 sc.setdefault('data_type', None)
390 sc.setdefault('item_name', sn) 390 sc.setdefault('item_name', sn)
391 sc.setdefault('items_per_page', 5) 391 sc.setdefault('items_per_page', 5)
392 sc.setdefault('date_format', DEFAULT_DATE_FORMAT) 392 sc.setdefault('date_format', DEFAULT_DATE_FORMAT)
393 sc.setdefault('realm', REALM_USER) 393 sc.setdefault('realm', REALM_USER)
394 sc.setdefault('pipeline', 'page') 394 sc.setdefault('pipeline', 'page')
410 raise ConfigurationError("The 'site/routes' setting must be a " 410 raise ConfigurationError("The 'site/routes' setting must be a "
411 "list.") 411 "list.")
412 412
413 # Check routes are referencing correct sources, have default 413 # Check routes are referencing correct sources, have default
414 # values, etc. 414 # values, etc.
415 used_sources = set()
416 existing_sources = set(values['site']['sources'].keys())
415 for rc in v: 417 for rc in v:
416 if not isinstance(rc, dict): 418 if not isinstance(rc, dict):
417 raise ConfigurationError("All routes in 'site/routes' must be " 419 raise ConfigurationError("All routes in 'site/routes' must be "
418 "dictionaries.") 420 "dictionaries.")
419 rc_url = rc.get('url') 421 rc_url = rc.get('url')
424 raise ConfigurationError("Route URLs must start with '/'.") 426 raise ConfigurationError("Route URLs must start with '/'.")
425 427
426 r_source = rc.get('source') 428 r_source = rc.get('source')
427 if r_source is None: 429 if r_source is None:
428 raise ConfigurationError("Routes must specify a source.") 430 raise ConfigurationError("Routes must specify a source.")
429 if (r_source and 431 if r_source not in existing_sources:
430 r_source not in list(values['site']['sources'].keys())):
431 raise ConfigurationError("Route is referencing unknown " 432 raise ConfigurationError("Route is referencing unknown "
432 "source: %s" % r_source) 433 "source: %s" % r_source)
433 434 if r_source in used_sources:
434 rc.setdefault('pass', 0) 435 raise ConfigurationError("Source '%s' already has a route." %
436 r_source)
437 used_sources.add(r_source)
438
435 rc.setdefault('page_suffix', '/%num%') 439 rc.setdefault('page_suffix', '/%num%')
436 440
437 return v 441 return v
438 442
439 443