diff piecrust/data/provider.py @ 815:69d16e1afb95

internal: Keep things out of the `PieCrust` class, and other clean-ups.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 11 Jan 2017 09:01:01 -0800
parents 37bd88f88bab
children
line wrap: on
line diff
--- a/piecrust/data/provider.py	Wed Dec 28 01:27:02 2016 -0500
+++ b/piecrust/data/provider.py	Wed Jan 11 09:01:01 2017 -0800
@@ -1,10 +1,21 @@
 import time
 import collections.abc
+from piecrust.configuration import ConfigurationError
 from piecrust.data.iterators import PageIterator
 from piecrust.generation.taxonomy import Taxonomy
 from piecrust.sources.array import ArraySource
 
 
+def get_data_provider_class(app, provider_type):
+    if not provider_type:
+        raise Exception("No data provider type specified.")
+    for prov in app.plugin_loader.getDataProviders():
+        if prov.PROVIDER_NAME == provider_type:
+            return prov
+    raise ConfigurationError(
+        "Unknown data provider type: %s" % provider_type)
+
+
 class DataProvider(object):
     debug_render_dynamic = []
     debug_render_invoke_dynamic = []