diff piecrust/data/linker.py @ 381:4c9eab0e283b

data: Fix problems with using non-existing metadata on a linked page. The page data wrapper now has supports for loader to raise a custom exception to declare that they can't return a value after all (this is especially useful for the wildcard loader). The returned value, if any, is also now cached properly.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 10 May 2015 00:37:28 -0700
parents 2408eb6f4da8
children 8e1e55ad35fb
line wrap: on
line diff
--- a/piecrust/data/linker.py	Sun May 10 00:34:21 2015 -0700
+++ b/piecrust/data/linker.py	Sun May 10 00:37:28 2015 -0700
@@ -1,8 +1,7 @@
 import logging
 import collections
-from piecrust.data.base import PaginationData
+from piecrust.data.base import PaginationData, LazyPageConfigLoaderHasNoValue
 from piecrust.data.iterators import PageIterator
-from piecrust.sources.base import build_pages
 from piecrust.sources.interfaces import IPaginationSource, IListableSource
 
 
@@ -53,8 +52,10 @@
 
         self.mapLoader('*', self._linkerChildLoader)
 
-    def _linkerChildLoader(self, name):
-        return getattr(self.children, name)
+    def _linkerChildLoader(self, data, name):
+        if self.children and hasattr(self.children, name):
+            return getattr(self.children, name)
+        raise LazyPageConfigLoaderHasNoValue
 
 
 class LinkedPageDataBuilderIterator(object):