Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
665:5dc13c816045 | 666:81d9c3a3a0b5 |
---|---|
87 self.start_time = time.perf_counter() | 87 self.start_time = time.perf_counter() |
88 self.exec_info_stack.clear() | 88 self.exec_info_stack.clear() |
89 self.was_cache_cleaned = False | 89 self.was_cache_cleaned = False |
90 self.base_asset_url_format = '%uri%' | 90 self.base_asset_url_format = '%uri%' |
91 | 91 |
92 self._onSubCacheDirChanged(app) | 92 for name, repo in self.fs_caches.items(): |
93 cache = app.cache.getCache(name) | |
94 repo.fs_cache = cache | |
93 | 95 |
94 def registerTimer(self, category, *, raise_if_registered=True): | 96 def registerTimer(self, category, *, raise_if_registered=True): |
95 if raise_if_registered and category in self._timers: | 97 if raise_if_registered and category in self._timers: |
96 raise Exception("Timer '%s' has already been registered." % | 98 raise Exception("Timer '%s' has already been registered." % |
97 category) | 99 category) |
107 self._timers[category] += value | 109 self._timers[category] += value |
108 | 110 |
109 def stepTimerSince(self, category, since): | 111 def stepTimerSince(self, category, since): |
110 self.stepTimer(category, time.perf_counter() - since) | 112 self.stepTimer(category, time.perf_counter() - since) |
111 | 113 |
112 def _onSubCacheDirChanged(self, app): | |
113 for name, repo in self.fs_caches.items(): | |
114 cache = app.cache.getCache(name) | |
115 repo.fs_cache = cache | |
116 | |
117 | 114 |
118 class StandardEnvironment(Environment): | 115 class StandardEnvironment(Environment): |
119 def __init__(self): | 116 def __init__(self): |
120 super(StandardEnvironment, self).__init__() | 117 super(StandardEnvironment, self).__init__() |
121 | 118 |