Actually implement a working NullSessionInterface, fixes pgjones/quart#105, bump version
This commit is contained in:
@@ -98,6 +98,10 @@ class Session(object):
|
|||||||
app.logger.warning("Deprecation: `SESSION_HIJACK_REVERSE_PROXY` "
|
app.logger.warning("Deprecation: `SESSION_HIJACK_REVERSE_PROXY` "
|
||||||
"has been renamed to `SESSION_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':
|
if config['SESSION_TYPE'] == 'redis':
|
||||||
options = {
|
options = {
|
||||||
"redis": config['SESSION_REDIS'],
|
"redis": config['SESSION_REDIS'],
|
||||||
@@ -129,7 +133,15 @@ class Session(object):
|
|||||||
use_signer=config['SESSION_USE_SIGNER'],
|
use_signer=config['SESSION_USE_SIGNER'],
|
||||||
permanent=config['SESSION_PERMANENT'],
|
permanent=config['SESSION_PERMANENT'],
|
||||||
**config)
|
**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:
|
else:
|
||||||
session_interface = NullSessionInterface()
|
raise NotImplementedError(f"No such session interface "
|
||||||
|
f"\"{config['SESSION_TYPE']}\". {backend_warning}")
|
||||||
|
|
||||||
return session_interface
|
return session_interface
|
||||||
|
|||||||
@@ -354,8 +354,23 @@ class MemcachedSessionInterface(SessionInterface):
|
|||||||
|
|
||||||
|
|
||||||
class NullSessionInterface(SessionInterface):
|
class NullSessionInterface(SessionInterface):
|
||||||
"""Used to open a :class:`quart.sessions.NullSession` instance.
|
"""This class does absolutely nothing"""
|
||||||
"""
|
session_class = NullSession
|
||||||
|
|
||||||
def open_session(self, app: Quart, request: BaseRequestWebsocket):
|
def __init__(
|
||||||
return None
|
self, key_prefix: str, use_signer: bool = False,
|
||||||
|
permanent: bool = True, **kwargs):
|
||||||
|
super(NullSessionInterface, self).__init__(
|
||||||
|
key_prefix=key_prefix, use_signer=use_signer,
|
||||||
|
permanent=permanent, **kwargs)
|
||||||
|
self.backend = None
|
||||||
|
|
||||||
|
async def create(self, app: Quart) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def get(self, key: str, app: Quart = None) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def set(self, key: str, value, expiry: int = None,
|
||||||
|
app: Quart = None) -> None:
|
||||||
|
pass
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ INSTALL_REQUIRES = [
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='Quart-Session',
|
name='Quart-Session',
|
||||||
version='1.0.0',
|
version='1.0.1',
|
||||||
url='https://github.com/sferdi0/quart-session',
|
url='https://github.com/sferdi0/quart-session',
|
||||||
license='BSD',
|
license='BSD',
|
||||||
author='Sander',
|
author='Sander',
|
||||||
|
|||||||
Reference in New Issue
Block a user