Actually implement a working NullSessionInterface, fixes pgjones/quart#105, bump version

This commit is contained in:
Sander
2020-07-08 17:07:58 +02:00
committed by sander
parent 51668878df
commit e136ab0101
3 changed files with 33 additions and 6 deletions
+13 -1
View File
@@ -98,6 +98,10 @@ class Session(object):
app.logger.warning("Deprecation: `SESSION_HIJACK_REVERSE_PROXY` "
"has been renamed to `SESSION_REVERSE_PROXY`")
backend_warning = f"Please specify a session backend. " \
f"Available interfaces: redis, redis+trio, " \
f"memcached, null. e.g: app.config['SESSION_TYPE'] = 'redis'"
if config['SESSION_TYPE'] == 'redis':
options = {
"redis": config['SESSION_REDIS'],
@@ -129,7 +133,15 @@ class Session(object):
use_signer=config['SESSION_USE_SIGNER'],
permanent=config['SESSION_PERMANENT'],
**config)
elif config['SESSION_TYPE'] == 'null':
app.logger.warning(f"{backend_warning}. Currently using: null")
session_interface = NullSessionInterface(
key_prefix=config['SESSION_KEY_PREFIX'],
use_signer=config['SESSION_USE_SIGNER'],
permanent=config['SESSION_PERMANENT'],
**config)
else:
session_interface = NullSessionInterface()
raise NotImplementedError(f"No such session interface "
f"\"{config['SESSION_TYPE']}\". {backend_warning}")
return session_interface