From 8d78368db340d3ab4b71c0db905a1de6621f0bf3 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Sun, 7 Mar 2021 20:01:48 +0100 Subject: [PATCH] Move logging to __init__ and cache a bit less. --- app/__init__.py | 13 ++++++++++++- app/agora.py | 7 ------- app/db.py | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index d5f21e87e..99c016cf5 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. import bleach +import logging import os from flask import Flask from flask_caching import Cache @@ -22,6 +23,11 @@ from . import util from flask_cors import CORS cache = Cache() +logging.basicConfig( + filename='agora.log', + level=logging.WARNING, + format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s' + ) # what is this doing here, I have no idea. # todo: move to util. @@ -39,7 +45,12 @@ def create_app(test_config=None): CORS(app) cache.init_app(app, config={ 'CACHE_TYPE': 'SimpleCache', - 'CACHE_DEFAULT_TIMEOUT': 30, + 'CACHE_DEFAULT_TIMEOUT': 60, + #'CACHE_TYPE': 'FileSystemCache', + #'CACHE_DIR': '/tmp', + #'CACHE_TYPE': 'MemcachedCache', + #'CACHE_THRESHOLD': 10, + #'CACHE_MEMCACHED_SERVERS': 'localhost', #'CACHE_KEY_PREFIX': 'agora', #'CACHE_REDIS_HOST': 'localhost', }) diff --git a/app/agora.py b/app/agora.py index 7b835e713..818920d6f 100644 --- a/app/agora.py +++ b/app/agora.py @@ -13,7 +13,6 @@ # limitations under the License. import datetime -import logging import jsons from flask import Blueprint, url_for, render_template, current_app, Response, redirect, request, jsonify from markupsafe import escape @@ -27,12 +26,6 @@ from . import util bp = Blueprint('agora', __name__) G = db.G -logging.basicConfig( - filename='agora.log', - level=logging.WARNING, - format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s' - ) - # Special @bp.route('/index') @bp.route('/') diff --git a/app/db.py b/app/db.py index 2eeeb454c..d6dd97036 100644 --- a/app/db.py +++ b/app/db.py @@ -112,7 +112,7 @@ class Graph: # Running something like this would be ideal eventually though. # It might also work better once all pulling/pushing logic moves to Graph, where it belongs, # and can make use of more sensible algorithms. - @cache.memoize(timeout=30) + # @cache.memoize(timeout=30) def compute_transclusion(self, include_journals=True): # Add artisanal virtual subnodes (resulting from transclusion/[[push]]) to all nodes. @@ -121,7 +121,7 @@ class Graph: node.subnodes.extend(pushed_subnodes) # does this belong here? - @cache.memoize(timeout=30) + # @cache.memoize(timeout=30) def subnodes(self, sort=lambda x: x.uri.lower()): # Markdown. subnodes = [Subnode(f) for f in glob.glob(os.path.join(config.AGORA_PATH, '**/*.md'), recursive=True)]