diff piecrust/data/pagedata.py @ 854:08e02c2a2a1a

core: Keep refactoring, this time to prepare for generator sources. - Make a few APIs simpler. - Content pipelines create their own jobs, so that generator sources can keep aborting in `getContents`, but rely on their pipeline to generate pages for baking.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 04 Jun 2017 23:34:28 -0700
parents 4850f8c21b6e
children f4608e2e80ce
line wrap: on
line diff
--- a/piecrust/data/pagedata.py	Sun May 21 00:06:59 2017 -0700
+++ b/piecrust/data/pagedata.py	Sun Jun 04 23:34:28 2017 -0700
@@ -76,7 +76,7 @@
                 logger.exception(ex)
                 raise Exception(
                     "Error while loading attribute '%s' for: %s" %
-                    (name, self._page.rel_path)) from ex
+                    (name, self._page.content_spec)) from ex
 
             # Forget this loader now that it served its purpose.
             try:
@@ -96,11 +96,14 @@
                 logger.exception(ex)
                 raise Exception(
                     "Error while loading attribute '%s' for: %s" %
-                    (name, self._page.rel_path)) from ex
+                    (name, self._page.content_spec)) from ex
             # We always keep the wildcard loader in the loaders list.
-            return self._values[name]
+            try:
+                return self._values[name]
+            except KeyError:
+                pass
 
-        raise LazyPageConfigLoaderHasNoValue("No such value: %s" % name)
+        raise LazyPageConfigLoaderHasNoValue()
 
     def _setValue(self, name, value):
         self._values[name] = value
@@ -136,7 +139,7 @@
             logger.exception(ex)
             raise Exception(
                 "Error while loading data for: %s" %
-                self._page.rel_path) from ex
+                self._page.content_spec) from ex
 
     def _load(self):
         pass
@@ -162,7 +165,7 @@
         dt = page.datetime
         for k, v in page.source_metadata.items():
             self._setValue(k, v)
-        self._setValue('url', self._ctx.uri)
+        self._setValue('url', self._page.getUri(self._ctx.sub_num))
         self._setValue('timestamp', time.mktime(dt.timetuple()))
         self._setValue('datetime', {
             'year': dt.year, 'month': dt.month, 'day': dt.day,