diff piecrust/sources/list.py @ 857:d231a10d18f9

refactor: Make the data providers and blog archives source functional. Also, because of a behaviour change in Jinja, the blog archives sources is now offering monthly archives by itself.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 08 Jun 2017 08:49:33 -0700
parents
children 8adc27285d93
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/sources/list.py	Thu Jun 08 08:49:33 2017 -0700
@@ -0,0 +1,31 @@
+from piecrust.sources.base import ContentSource
+
+
+class ListSource(ContentSource):
+    def __init__(self, inner_source, items):
+        super().__init__(
+            inner_source.app, inner_source.name, inner_source.config)
+
+        self.inner_source = inner_source
+        self.items = items
+
+    def openItem(self, item, mode='r', **kwargs):
+        return self.inner_source.openItem(item, mode, **kwargs)
+
+    def getItemMtime(self, item):
+        return self.inner_source.getItemMtime(item)
+
+    def getContents(self, group):
+        return self.items
+
+    def getRelatedContents(self, item, relationship):
+        return self.inner_source.getRelatedContents(item, relationship)
+
+    def findContent(self, route_params):
+        # Can't find items... we could find stuff that's not in our list?
+        raise NotImplementedError(
+            "The list source doesn't support finding items.")
+
+    def getSupportedRouteParameters(self):
+        return self.inner_source.getSupportedRouteParameters()
+