Move REQUEST_TYPES, RESPONSE_TYPES to voussoirkit.flasktools.
This commit is contained in:
parent
0012999744
commit
53e8030186
2 changed files with 4 additions and 6 deletions
|
@ -174,7 +174,7 @@ def render_template(request, template_name, **kwargs):
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not isinstance(response, sessions.RESPONSE_TYPES):
|
if not isinstance(response, flasktools.RESPONSE_TYPES):
|
||||||
response = flask.Response(response)
|
response = flask.Response(response)
|
||||||
|
|
||||||
if new_theme is None:
|
if new_theme is None:
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
import flask; from flask import request
|
import flask; from flask import request
|
||||||
import functools
|
import functools
|
||||||
import werkzeug.wrappers
|
|
||||||
import werkzeug.datastructures
|
import werkzeug.datastructures
|
||||||
|
|
||||||
from voussoirkit import cacheclass
|
from voussoirkit import cacheclass
|
||||||
|
from voussoirkit import flasktools
|
||||||
from voussoirkit import passwordy
|
from voussoirkit import passwordy
|
||||||
|
|
||||||
import etiquette
|
import etiquette
|
||||||
|
|
||||||
SESSION_MAX_AGE = 86400
|
SESSION_MAX_AGE = 86400
|
||||||
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 passwordy.random_hex(length=length)
|
return passwordy.random_hex(length=length)
|
||||||
|
|
||||||
def _normalize_token(token):
|
def _normalize_token(token):
|
||||||
if isinstance(token, REQUEST_TYPES):
|
if isinstance(token, flasktools.REQUEST_TYPES):
|
||||||
request = token
|
request = token
|
||||||
token = request.cookies.get('etiquette_session', None)
|
token = request.cookies.get('etiquette_session', None)
|
||||||
if token is None:
|
if token is None:
|
||||||
|
@ -81,7 +79,7 @@ class SessionManager:
|
||||||
session.maintain()
|
session.maintain()
|
||||||
|
|
||||||
response = function(*args, **kwargs)
|
response = function(*args, **kwargs)
|
||||||
if not isinstance(response, RESPONSE_TYPES):
|
if not isinstance(response, flasktools.RESPONSE_TYPES):
|
||||||
response = flask.Response(response)
|
response = flask.Response(response)
|
||||||
|
|
||||||
# Send the token back to the client
|
# Send the token back to the client
|
||||||
|
|
Loading…
Reference in a new issue