Skip to content

Commit

Permalink
Merge pull request #55 from ctreffe/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jobrachem authored May 14, 2021
2 parents 4058cbd + 3a17a90 commit 7dd8aef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ build/
dist/
mortimer_venv/
.mortimer/
.venv/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Mortimer v0.8.6 (Released 2021-05-14)

### Changed v0.8.6

- Increased timeout before experiment sessions are removed by mortimer.

## Mortimer v0.8.5 (Released 2021-04-20)

### Changed v0.8.5
Expand Down
2 changes: 1 addition & 1 deletion src/mortimer/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module

__version__ = "0.8.5"
__version__ = "0.8.6"
34 changes: 17 additions & 17 deletions src/mortimer/web_experiments/alfredo.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def import_script(experiment_id):


class ExperimentManager(object):
def __init__(self, timeout=3600):
def __init__(self, timeout=60 * 60 * 24 * 2):
self.timeout = timeout
self.experiments = {}
self.lock = Lock()
Expand Down Expand Up @@ -235,20 +235,32 @@ def experiment():
sid = session["sid"]
except KeyError:
abort(412)
return

experiment = experiment_manager.get(sid)
tkey = experiment.current_page.name + sid

try:
if request.method == "POST":
if request.method == "GET":
url_pagename = request.args.get("page", None) # https://basepath.de/experiment?page=name
if url_pagename:
experiment.movement_manager.jump_by_name(name=url_pagename)

token = session["page_tokens"].get(tkey, uuid4().hex)
session["page_tokens"][tkey] = token
session.modified = True # because the dict is mutable

current_page_html = make_response(experiment.ui.render_html(token))
current_page_html.cache_control.no_cache = True
return current_page_html

elif request.method == "POST":
move = request.values.get("move", None)
submitted_token = request.values.get("page_token", None)

token = session["page_tokens"].pop(tkey, None)
session.modified = True # because the dict is mutable
if not token or not token == submitted_token:
return redirect(url_for("alfredo.experiment"))
session.modified = True # because the dict is mutable


data = request.values.to_dict()
Expand All @@ -264,19 +276,7 @@ def experiment():
else:
abort(400)
return redirect(url_for("alfredo.experiment"))

elif request.method == "GET":
url_pagename = request.args.get("page", None) # https://basepath.de/experiment?page=name
if url_pagename:
experiment.movement_manager.jump_by_name(name=url_pagename)

token = session["page_tokens"].get(tkey, uuid4().hex)
session["page_tokens"][tkey] = token
session.modified = True # because the dict is mutable

resp = make_response(experiment.user_interface_controller.render_html(token))
resp.cache_control.no_cache = True
return resp

except Exception:
log = alfredlog.QueuedLoggingInterface("alfred3", f"exp.{str(experiment.exp_id)}")
log.session_id = sid
Expand Down

0 comments on commit 7dd8aef

Please sign in to comment.