Add constant RESPONSE_TYPES for use in isinstance checks.

master
voussoir 2020-09-09 18:53:51 -07:00
parent 049d620789
commit 2ba4a3bb91
1 changed files with 2 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import etiquette
SESSION_MAX_AGE = 86400 SESSION_MAX_AGE = 86400
REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy) REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy)
RESPONSE_TYPES = (flask.Response, werkzeug.wrappers.Response)
def _generate_token(length=32): def _generate_token(length=32):
return etiquette.helpers.random_hex(length=length) return etiquette.helpers.random_hex(length=length)
@ -81,7 +82,7 @@ class SessionManager:
session.maintain() session.maintain()
response = function(*args, **kwargs) response = function(*args, **kwargs)
if not isinstance(response, (flask.Response, werkzeug.wrappers.Response)): if not isinstance(response, RESPONSE_TYPES):
response = flask.Response(response) response = flask.Response(response)
# Send the token back to the client # Send the token back to the client