diff piecrust/serving/procloop.py @ 663:3ceeca7bb71c

themes: Add support for a `--theme` argument to `chef`.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 01 Mar 2016 22:27:28 -0800
parents 7dabfdd056a1
children 81d9c3a3a0b5
line wrap: on
line diff
--- a/piecrust/serving/procloop.py	Tue Mar 01 22:27:04 2016 -0800
+++ b/piecrust/serving/procloop.py	Tue Mar 01 22:27:28 2016 -0800
@@ -6,6 +6,7 @@
 import logging
 import itertools
 import threading
+from piecrust import CONFIG_PATH, THEME_CONFIG_PATH
 from piecrust.app import PieCrust
 from piecrust.processing.pipeline import ProcessorPipeline
 
@@ -74,25 +75,30 @@
 
 
 class ProcessingLoop(threading.Thread):
-    def __init__(self, root_dir, out_dir, sub_cache_dir=None, debug=False):
+    def __init__(self, root_dir, out_dir, sub_cache_dir=None,
+                 theme_site=False, debug=False):
         super(ProcessingLoop, self).__init__(
                 name='pipeline-reloader', daemon=True)
         self.root_dir = root_dir
         self.out_dir = out_dir
         self.sub_cache_dir = sub_cache_dir
         self.debug = debug
+        self.theme_site = theme_site
         self.last_status_id = 0
         self.interval = 1
         self.app = None
         self._roots = []
         self._monitor_assets_root = False
         self._paths = set()
-        self._config_path = os.path.join(root_dir, 'config.yml')
         self._record = None
         self._last_bake = 0
         self._last_config_mtime = 0
         self._obs = []
         self._obs_lock = threading.Lock()
+        if theme_site:
+            self._config_path = os.path.join(root_dir, THEME_CONFIG_PATH)
+        else:
+            self._config_path = os.path.join(root_dir, CONFIG_PATH)
 
     def addObserver(self, obs):
         with self._obs_lock:
@@ -156,7 +162,8 @@
 
     def _initPipeline(self):
         # Create the app and pipeline.
-        self.app = PieCrust(root_dir=self.root_dir, debug=self.debug)
+        self.app = PieCrust(root_dir=self.root_dir, debug=self.debug,
+                            theme_site=self.theme_site)
         if self.sub_cache_dir:
             self.app._useSubCacheDir(self.sub_cache_dir)
         self.pipeline = ProcessorPipeline(self.app, self.out_dir)