gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-blog] branch master updated: use uwsgi cache


From: gnunet
Subject: [GNUnet-SVN] [taler-blog] branch master updated: use uwsgi cache
Date: Mon, 22 Jan 2018 02:08:36 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository blog.

The following commit(s) were added to refs/heads/master by this push:
     new eb8c5b2  use uwsgi cache
eb8c5b2 is described below

commit eb8c5b2386322865452e558e85c85d88ec574c94
Author: Florian Dold <address@hidden>
AuthorDate: Mon Jan 22 02:06:32 2018 +0100

    use uwsgi cache
---
 taler-merchant-blog.in             |  3 ++-
 talerblog/blog/blog.py             | 12 ++++++++----
 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 &quot;Free 
Software, Free Society&quot;,
        which is also
       <a 
href="http://shop.fsf.org/product/free-software-free-society-2/";>published by 
the FSF</a>

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]