aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-07-07 23:03:41 +0200
committerDaniel Schadt <kingdread@gmx.de>2022-07-07 23:06:12 +0200
commitcae213ace633fdb0b23c0cc512cac23f58aedde5 (patch)
tree5e180084f19453785b5eb9a0c9b0f00456897905
parent264612664a24447c929cfd71659d44dd95a8e3a9 (diff)
downloadfietsboek-cae213ace633fdb0b23c0cc512cac23f58aedde5.tar.gz
fietsboek-cae213ace633fdb0b23c0cc512cac23f58aedde5.tar.bz2
fietsboek-cae213ace633fdb0b23c0cc512cac23f58aedde5.zip
wire jinja2 filters in code
Those things are not really a configuration thing that changes, rather they are part of how the code of the application works. As such, it doesn't make too much sense to require those configuration values. Instead, we now add those filters programatically. This also ensures that the filters are the same between development, production and testing environment.
-rw-r--r--development.ini3
-rw-r--r--fietsboek/__init__.py8
-rw-r--r--production.ini3
3 files changed, 7 insertions, 7 deletions
diff --git a/development.ini b/development.ini
index 15250c4..47e0231 100644
--- a/development.ini
+++ b/development.ini
@@ -16,9 +16,6 @@ pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar
-jinja2.filters =
- format_decimal = fietsboek.jinja2.filter_format_decimal
- format_datetime = fietsboek.jinja2.filter_format_datetime
sqlalchemy.url = sqlite:///%(here)s/fietsboek.sqlite
diff --git a/fietsboek/__init__.py b/fietsboek/__init__.py
index 98e6846..6ed9028 100644
--- a/fietsboek/__init__.py
+++ b/fietsboek/__init__.py
@@ -8,6 +8,7 @@ from pyramid.settings import asbool, aslist
from pyramid.i18n import default_locale_negotiator
from .security import SecurityPolicy
+from . import jinja2 as fiets_jinja2
def locale_negotiator(request):
@@ -41,7 +42,7 @@ def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# pylint: disable=unused-argument
- if 'session_key' not in settings:
+ if settings.get('session_key', '<EDIT THIS>') == '<EDIT THIS>':
raise ValueError("Please set a session signing key (session_key) in your settings!")
settings['enable_account_registration'] = asbool(
@@ -59,4 +60,9 @@ def main(global_config, **settings):
config.set_session_factory(my_session_factory)
config.set_security_policy(SecurityPolicy())
config.set_locale_negotiator(locale_negotiator)
+
+ jinja2_env = config.get_jinja2_environment()
+ jinja2_env.filters['format_decimal'] = fiets_jinja2.filter_format_decimal
+ jinja2_env.filters['format_datetime'] = fiets_jinja2.filter_format_datetime
+
return config.make_wsgi_app()
diff --git a/production.ini b/production.ini
index 9dd45c2..2a822d5 100644
--- a/production.ini
+++ b/production.ini
@@ -11,9 +11,6 @@ pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
-jinja2.filters =
- format_decimal = fietsboek.jinja2.filter_format_decimal
- format_datetime = fietsboek.jinja2.filter_format_datetime
email.from = fietsboek@kingdread.de
email.smtp_url = debug://localhost:1025