Exactract "formCache' into form_cache.PARAM_NAME
This commit is contained in:
parent
de12aee163
commit
1d5bfed556
@ -97,8 +97,10 @@ def _make_authentication_context():
|
||||
def redirect_after_login_url():
|
||||
if request.args.get("next"):
|
||||
returl = request.args.get("next")
|
||||
if request.args.get("formCache"):
|
||||
returl += "?" + url.urlencode({"formCache": request.args.get("formCache")})
|
||||
if request.args.get(app.form_cache.PARAM_NAME):
|
||||
returl += "?" + url.urlencode(
|
||||
{app.form_cache.PARAM_NAME: request.args.get(app.form_cache.PARAM_NAME)}
|
||||
)
|
||||
return returl
|
||||
else:
|
||||
return url_for("atst.home")
|
||||
|
@ -39,7 +39,7 @@ def make_error_pages(app):
|
||||
log_error(e)
|
||||
url_args = {"sessionExpired": True, "next": request.path}
|
||||
if request.method == "POST":
|
||||
url_args["formCache"] = app.form_cache.write(request.form)
|
||||
url_args[app.form_cache.PARAM_NAME] = app.form_cache.write(request.form)
|
||||
return redirect(url_for("atst.root", **url_args))
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
|
@ -7,11 +7,13 @@ DEFAULT_CACHE_NAME = "formcache"
|
||||
|
||||
|
||||
class FormCache(object):
|
||||
PARAM_NAME = "formCache"
|
||||
|
||||
def __init__(self, redis):
|
||||
self.redis = redis
|
||||
|
||||
def from_request(self, http_request):
|
||||
cache_key = http_request.args.get("formCache")
|
||||
cache_key = http_request.args.get(self.PARAM_NAME)
|
||||
if cache_key:
|
||||
return self.read(cache_key)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user