Mercurial > piecrust2
diff piecrust/serving/util.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 | 3ceeca7bb71c |
children | ab5c6a8ae90a |
line wrap: on
line diff
--- a/piecrust/serving/util.py Thu Mar 03 08:19:28 2016 -0800 +++ b/piecrust/serving/util.py Thu Mar 03 08:22:41 2016 -0800 @@ -5,7 +5,7 @@ import datetime from werkzeug.wrappers import Response from werkzeug.wsgi import wrap_file -from piecrust.app import PieCrust +from piecrust.app import PieCrust, apply_variant_and_values from piecrust.rendering import QualifiedPage from piecrust.routing import RouteNotFoundError from piecrust.sources.base import MODE_PARSING @@ -16,11 +16,8 @@ logger = logging.getLogger(__name__) -def get_app_for_server(root_dir, debug=False, theme_site=False, - sub_cache_dir=None, root_url='/'): - app = PieCrust(root_dir=root_dir, debug=debug, theme_site=theme_site) - if sub_cache_dir: - app._useSubCacheDir(sub_cache_dir) +def get_app_for_server(appfactory, root_url='/'): + app = appfactory.create() app.config.set('site/root', root_url) app.config.set('server/is_serving', True) return app