Mercurial > piecrust2
comparison piecrust/commands/builtin/serving.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 | 4850f8c21b6e |
comparison
equal
deleted
inserted
replaced
665:5dc13c816045 | 666:81d9c3a3a0b5 |
---|---|
40 root_dir = ctx.app.root_dir | 40 root_dir = ctx.app.root_dir |
41 host = ctx.args.address | 41 host = ctx.args.address |
42 port = int(ctx.args.port) | 42 port = int(ctx.args.port) |
43 debug = ctx.args.debug or ctx.args.use_debugger | 43 debug = ctx.args.debug or ctx.args.use_debugger |
44 | 44 |
45 from piecrust.app import PieCrustFactory | |
46 appfactory = PieCrustFactory( | |
47 ctx.app.root_dir, | |
48 cache=ctx.app.cache.enabled, | |
49 cache_key=ctx.app.cache_key, | |
50 config_variant=ctx.config_variant, | |
51 config_values=ctx.config_values, | |
52 debug=ctx.app.debug, | |
53 theme_site=ctx.app.theme_site) | |
54 | |
45 if ctx.args.wsgi == 'werkzeug': | 55 if ctx.args.wsgi == 'werkzeug': |
46 run_werkzeug_server( | 56 run_werkzeug_server( |
47 root_dir, host, port, | 57 appfactory, host, port, |
48 debug_piecrust=debug, | |
49 theme_site=ctx.args.theme, | |
50 sub_cache_dir=ctx.app.sub_cache_dir, | |
51 use_debugger=debug, | 58 use_debugger=debug, |
52 use_reloader=ctx.args.use_reloader) | 59 use_reloader=ctx.args.use_reloader) |
53 | 60 |
54 elif ctx.args.wsgi == 'gunicorn': | 61 elif ctx.args.wsgi == 'gunicorn': |
55 options = { | 62 options = { |
58 } | 65 } |
59 if debug: | 66 if debug: |
60 options['loglevel'] = 'debug' | 67 options['loglevel'] = 'debug' |
61 if ctx.args.use_reloader: | 68 if ctx.args.use_reloader: |
62 options['reload'] = True | 69 options['reload'] = True |
63 run_gunicorn_server( | 70 run_gunicorn_server(appfactory, gunicorn_options=options) |
64 root_dir, | |
65 debug_piecrust=debug, | |
66 theme_site=ctx.args.theme, | |
67 sub_cache_dir=ctx.app.sub_cache_dir, | |
68 gunicorn_options=options) | |
69 | 71 |