summaryrefslogtreecommitdiff
path: root/talerblog/blog/blog.py
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-01-22 02:06:32 +0100
committerFlorian Dold <florian.dold@gmail.com>2018-01-22 02:08:18 +0100
commiteb8c5b2386322865452e558e85c85d88ec574c94 (patch)
tree0231bc00e497cabc7d5911f5ca657745202816b0 /talerblog/blog/blog.py
parentb95ad6559fc584f0dfa1b4366c917f9556d0ac6d (diff)
downloadblog-eb8c5b2386322865452e558e85c85d88ec574c94.tar.gz
blog-eb8c5b2386322865452e558e85c85d88ec574c94.tar.bz2
blog-eb8c5b2386322865452e558e85c85d88ec574c94.zip
use uwsgi cache
Diffstat (limited to 'talerblog/blog/blog.py')
-rw-r--r--talerblog/blog/blog.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/talerblog/blog/blog.py b/talerblog/blog/blog.py
index 1adcb7f..25f5687 100644
--- a/talerblog/blog/blog.py
+++ b/talerblog/blog/blog.py
@@ -28,7 +28,7 @@ import uuid
import base64
import requests
import flask
-from werkzeug.contrib.cache import SimpleCache
+from werkzeug.contrib.cache import UWSGICache, SimpleCache
from talerblog.talerconfig import TalerConfig
from ..blog.content import ARTICLES, get_article_file, get_image_file
@@ -113,7 +113,11 @@ def javascript_licensing():
# Cache for paid articles (in the form <session_id>-<article_name>), so we
# don't always have to ask the backend / DB, and so we don't have to store
# variable-size cookies on the client.
-paid_articles_cache = SimpleCache()
+try:
+ paid_articles_cache = UWSGICache(0, "paid_articles")
+except ImportError:
+ paid_articles_cache = SimpleCache()
+
# Triggers the refund by serving /refund/test?order_id=XY.
@@ -170,12 +174,12 @@ def article(article_name, data=None):
# We use an explicit session ID so that each payment (or payment replay) is
# bound to a browser. This forces re-play and prevents sharing the article
# by just sharing the URL.
- session_id = flask.session.get("uid")
+ session_id = flask.session.get("session_id")
order_id = flask.request.args.get("order_id")
session_sig = flask.request.args.get("session_sig")
if not session_id:
- session_id = flask.session["uid"] = str(uuid.uuid4())
+ session_id = flask.session["session_id"] = str(uuid.uuid4())
cached_order_id = paid_articles_cache.get(session_id + "-" + article_name)
if cached_order_id: