diff piecrust/environment.py @ 666:81d9c3a3a0b5

internal: Get rid of the whole "sub cache" business. * Compute cache keys up front, so the cache directory is only chosen once. * Buffer up config variants to apply before loading the config. Makes it possible to cache variant-resulting configs, too. * Make a factory class to reuse the logic that creates the `PieCrust` object correctly for multi-process workers and such. * Add a test.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 03 Mar 2016 08:22:41 -0800
parents cb3446be44b7
children 61d606fbc313
line wrap: on
line diff
--- a/piecrust/environment.py	Thu Mar 03 08:19:28 2016 -0800
+++ b/piecrust/environment.py	Thu Mar 03 08:22:41 2016 -0800
@@ -89,7 +89,9 @@
         self.was_cache_cleaned = False
         self.base_asset_url_format = '%uri%'
 
-        self._onSubCacheDirChanged(app)
+        for name, repo in self.fs_caches.items():
+            cache = app.cache.getCache(name)
+            repo.fs_cache = cache
 
     def registerTimer(self, category, *, raise_if_registered=True):
         if raise_if_registered and category in self._timers:
@@ -109,11 +111,6 @@
     def stepTimerSince(self, category, since):
         self.stepTimer(category, time.perf_counter() - since)
 
-    def _onSubCacheDirChanged(self, app):
-        for name, repo in self.fs_caches.items():
-            cache = app.cache.getCache(name)
-            repo.fs_cache = cache
-
 
 class StandardEnvironment(Environment):
     def __init__(self):