diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-01-22 02:06:32 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-01-22 02:08:18 +0100 |
commit | eb8c5b2386322865452e558e85c85d88ec574c94 (patch) | |
tree | 0231bc00e497cabc7d5911f5ca657745202816b0 | |
parent | b95ad6559fc584f0dfa1b4366c917f9556d0ac6d (diff) | |
download | blog-eb8c5b2386322865452e558e85c85d88ec574c94.tar.gz blog-eb8c5b2386322865452e558e85c85d88ec574c94.tar.bz2 blog-eb8c5b2386322865452e558e85c85d88ec574c94.zip |
use uwsgi cache
-rw-r--r-- | taler-merchant-blog.in | 3 | ||||
-rw-r--r-- | talerblog/blog/blog.py | 12 | ||||
-rw-r--r-- | talerblog/blog/templates/base.html | 4 |
3 files changed, 12 insertions, 7 deletions
diff --git a/taler-merchant-blog.in b/taler-merchant-blog.in index ca1b7c7..0b25879 100644 --- a/taler-merchant-blog.in +++ b/taler-merchant-blog.in @@ -43,7 +43,8 @@ def handle_serve_uwsgi(args): "--master", "--die-on-term", "--log-format", UWSGI_LOGFMT, - "--wsgi-file", "@prefix@/share/taler/frontend-blog.wsgi"] + "--wsgi-file", "@prefix@/share/taler/frontend-blog.wsgi", + "--cache2", "name=paid_articles,items=500"] if serve_uwsgi == "tcp": port = TC["blog"]["uwsgi_port"].value_int(required=True) spec = ":%d" % (port,) 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: diff --git a/talerblog/blog/templates/base.html b/talerblog/blog/templates/base.html index 54ceb60..98ce2e3 100644 --- a/talerblog/blog/templates/base.html +++ b/talerblog/blog/templates/base.html @@ -17,6 +17,7 @@ <html data-taler-nojs="true"> <head> + <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Taler Donation Demo</title> <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='web-common/pure.css') }}" /> @@ -49,8 +50,7 @@ <div class="demobar" style="display: flex; flex-direction: column;"> <h1><span class="tt adorn-brackets">Taler Demo</span></h1> <h1><span class="it"><a href="{{ env('TALER_ENV_URL_MERCHANT_BLOG') }}">Shop</a></span></h1> - <p>This is the Essay shop, you can buy articles using an imaginary currency (for now).</p> - <p> + <p>On this page you can buy articles using an imaginary currency (for now). The articles are chapters from Richard Stallman's book "Free Software, Free Society", which is also <a href="http://shop.fsf.org/product/free-software-free-society-2/">published by the FSF</a> |