mirror of
https://github.com/flancian/garden.git
synced 2026-08-08 15:36:19 +00:00
Move logging to __init__ and cache a bit less.
This commit is contained in:
+12
-1
@@ -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',
|
||||
})
|
||||
|
||||
@@ -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('/')
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user