Mercurial > piecrust2
view piecrust/wsgiutil/__init__.py @ 1168:10520472cc73
routing: Fix breakages with routing on some versions of Python.
Finally figured what happened with change 6baa94da8b16 (this is a Mercurial
hash by the way if you're looking at the Git mirror). Between Python 3.6 and
3.7 there was a change where the percent sign ('%') went from being escaped by
`re.escape` to _not_ being escaped. So now we need to use different regex
patterns dependin on the Python version, yay.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 04 Oct 2019 11:13:33 -0700 |
parents | 7ecb946bfafd |
children | d0f86d9a9d40 |
line wrap: on
line source
import logging from piecrust.serving.wrappers import get_piecrust_server def _setup_logging(log_file, log_level, max_log_bytes, log_backup_count): if log_file: from logging.handlers import RotatingFileHandler handler = RotatingFileHandler(log_file, maxBytes=max_log_bytes, backupCount=log_backup_count) handler.setLevel(log_level) logging.getLogger().addHandler(handler) def get_app(root_dir, *, cache_key='prod', serve_admin=False, log_file=None, log_level=logging.INFO, log_backup_count=0, max_log_bytes=4096): _setup_logging(log_file, log_level, max_log_bytes, log_backup_count) app = get_piecrust_server(root_dir, serve_site=True, serve_admin=serve_admin, cache_key=cache_key) return app def get_admin_app(root_dir, *, cache_key='prod', log_file=None, log_level=logging.INFO, log_backup_count=0, max_log_bytes=4096): _setup_logging(log_file, log_level, max_log_bytes, log_backup_count) app = get_piecrust_server(root_dir, serve_site=False, serve_admin=True, cache_key=cache_key) return app