Mercurial > piecrust2
diff piecrust/commands/builtin/admin.py @ 597:79a31a3c947b
admin: Better production config for FoodTruck, provide proper first site.
* Use a `settings` object to configure Flask.
* Accept an `app.cfg` file in the admin folder to configure Flask.
* Get a proper first site name when the cookie isn't set yet.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 20 Jan 2016 21:39:18 -0800 |
parents | b884bef3e611 |
children | effbc78b5528 |
line wrap: on
line diff
--- a/piecrust/commands/builtin/admin.py Wed Jan 20 21:36:51 2016 -0800 +++ b/piecrust/commands/builtin/admin.py Wed Jan 20 21:39:18 2016 -0800 @@ -39,6 +39,8 @@ return ctx.args.sub_func(ctx) def _runFoodTruck(self, ctx): + from foodtruck import settings + settings.FOODTRUCK_CMDLINE_MODE = True from foodtruck.main import run_foodtruck run_foodtruck(debug=ctx.args.debug) @@ -61,21 +63,25 @@ admin_password = hashpw ft_config = """ -foodtruck: - secret_key: %(secret_key)s security: username: %(username)s # You can generate another hashed password with `chef admin genpass`. password: %(password)s """ ft_config = ft_config % { - 'secret_key': secret_key, 'username': admin_username, 'password': admin_password } with open('foodtruck.yml', 'w', encoding='utf8') as fp: fp.write(ft_config) + flask_config = """ +secret_key = '%(secret_key)s' +""" + flask_config = flask_config % {'secret_key': secret_key} + with open('app.cfg', 'w', encoding='utf8') as fp: + fp.write(flask_config) + def _generatePassword(self, ctx): import bcrypt binpw = ctx.args.password.encode('utf8')