diff --git a/realms/__init__.py b/realms/__init__.py index 8c4c571..27c63dc 100644 --- a/realms/__init__.py +++ b/realms/__init__.py @@ -13,10 +13,10 @@ import httplib import traceback import click from flask import Flask, request, render_template, url_for, redirect, g -from flask.ext.cache import Cache -from flask.ext.login import LoginManager, current_user -from flask.ext.sqlalchemy import SQLAlchemy -from flask.ext.assets import Environment, Bundle +from flask_cache import Cache +from flask_login import LoginManager, current_user +from flask_sqlalchemy import SQLAlchemy +from flask_assets import Environment, Bundle from flask_ldap_login import LDAPLoginManager from functools import update_wrapper from werkzeug.routing import BaseConverter @@ -180,9 +180,7 @@ def create_app(config=None): db.Model = declarative_base(metaclass=HookModelMeta, cls=HookMixin) - for status_code in httplib.responses: - if status_code >= 400: - app.register_error_handler(status_code, error_handler) + app.register_error_handler(HTTPException, error_handler) @app.before_request def init_g(): diff --git a/realms/commands.py b/realms/commands.py index ac228c9..c7ca43c 100644 --- a/realms/commands.py +++ b/realms/commands.py @@ -425,7 +425,7 @@ def clear_cache(): def test(): """ Run tests """ - for mod in [('flask.ext.testing', 'Flask-Testing'), ('nose', 'nose'), ('blinker', 'blinker')]: + for mod in [('flask_testing', 'Flask-Testing'), ('nose', 'nose'), ('blinker', 'blinker')]: if not module_exists(mod[0]): pip.main(['install', mod[1]]) diff --git a/realms/config/__init__.py b/realms/config/__init__.py index 4150a3d..32172f3 100644 --- a/realms/config/__init__.py +++ b/realms/config/__init__.py @@ -139,6 +139,7 @@ class Config(object): DEBUG = False ASSETS_DEBUG = False SQLALCHEMY_ECHO = False + SQLALCHEMY_TRACK_MODIFICATIONS = False MODULES = ['wiki', 'search', 'auth'] diff --git a/realms/lib/hook.py b/realms/lib/hook.py index 0327263..a607b54 100644 --- a/realms/lib/hook.py +++ b/realms/lib/hook.py @@ -1,4 +1,4 @@ -from flask.ext.sqlalchemy import DeclarativeMeta +from flask_sqlalchemy import DeclarativeMeta from functools import wraps diff --git a/realms/lib/test.py b/realms/lib/test.py index dd5b683..465b6f4 100644 --- a/realms/lib/test.py +++ b/realms/lib/test.py @@ -1,7 +1,7 @@ import os import shutil import tempfile -from flask.ext.testing import TestCase +from flask_testing import TestCase from realms.lib.util import random_string from realms import create_app diff --git a/realms/modules/auth/__init__.py b/realms/modules/auth/__init__.py index a33ffda..b8421e7 100644 --- a/realms/modules/auth/__init__.py +++ b/realms/modules/auth/__init__.py @@ -1,6 +1,6 @@ from realms import login_manager from flask import request, flash, redirect -from flask.ext.login import login_url +from flask_login import login_url modules = set() diff --git a/realms/modules/auth/ldap/models.py b/realms/modules/auth/ldap/models.py index c1c7176..1574eb8 100644 --- a/realms/modules/auth/ldap/models.py +++ b/realms/modules/auth/ldap/models.py @@ -1,5 +1,5 @@ from flask import render_template -from flask.ext.login import login_user +from flask_login import login_user from realms import ldap from flask_ldap_login import LDAPLoginForm from ..models import BaseUser diff --git a/realms/modules/auth/local/models.py b/realms/modules/auth/local/models.py index 695ce63..9e14ec8 100644 --- a/realms/modules/auth/local/models.py +++ b/realms/modules/auth/local/models.py @@ -1,5 +1,5 @@ from flask import current_app, render_template -from flask.ext.login import logout_user, login_user +from flask_login import logout_user, login_user from realms import login_manager, db from realms.lib.model import Model from ..models import BaseUser diff --git a/realms/modules/auth/models.py b/realms/modules/auth/models.py index f62b736..f5a0ec7 100644 --- a/realms/modules/auth/models.py +++ b/realms/modules/auth/models.py @@ -1,5 +1,5 @@ from flask import current_app -from flask.ext.login import UserMixin, logout_user, AnonymousUserMixin +from flask_login import UserMixin, logout_user, AnonymousUserMixin from realms import login_manager from realms.lib.util import gravatar_url from itsdangerous import URLSafeSerializer, BadSignature diff --git a/realms/modules/auth/views.py b/realms/modules/auth/views.py index 11b1472..40f5e47 100644 --- a/realms/modules/auth/views.py +++ b/realms/modules/auth/views.py @@ -1,5 +1,5 @@ from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for -from flask.ext.login import logout_user +from flask_login import logout_user from realms.modules.auth.models import Auth blueprint = Blueprint('auth', __name__, template_folder='templates') diff --git a/realms/modules/search/models.py b/realms/modules/search/models.py index 5a1a559..2935db7 100644 --- a/realms/modules/search/models.py +++ b/realms/modules/search/models.py @@ -14,7 +14,7 @@ def whoosh(app): def elasticsearch(app): - from flask.ext.elastic import Elastic + from flask_elastic import Elastic fields = app.config.get('ELASTICSEARCH_FIELDS') return ElasticSearch(Elastic(app), fields) diff --git a/realms/modules/wiki/views.py b/realms/modules/wiki/views.py index 017b7f9..70c5def 100644 --- a/realms/modules/wiki/views.py +++ b/realms/modules/wiki/views.py @@ -2,7 +2,7 @@ import itertools import sys from datetime import datetime from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app -from flask.ext.login import login_required, current_user +from flask_login import login_required, current_user from realms.lib.util import to_canonical, remove_ext, gravatar_url from .models import PageNotFound @@ -12,7 +12,7 @@ blueprint = Blueprint('wiki', __name__, template_folder='templates', @blueprint.route("/_commit//") def commit(name, sha): - if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous: return current_app.login_manager.unauthorized() cname = to_canonical(name) @@ -27,7 +27,7 @@ def commit(name, sha): @blueprint.route(r"/_compare//") def compare(name, fsha, dots, lsha): - if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous: return current_app.login_manager.unauthorized() diff = g.current_wiki.get_page(name, sha=lsha).compare(fsha) @@ -42,7 +42,7 @@ def revert(): commit = request.form.get('commit') message = request.form.get('message', "Reverting %s" % cname) - if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous(): + if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous: return dict(error=True, message="Anonymous posting not allowed"), 403 if cname in current_app.config.get('WIKI_LOCKED_PAGES'): @@ -64,7 +64,7 @@ def revert(): @blueprint.route("/_history/") def history(name): - if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous: return current_app.login_manager.unauthorized() return render_template('wiki/history.html', name=name) @@ -166,7 +166,7 @@ def _tree_index(items, path=""): @blueprint.route("/_index", defaults={"path": ""}) @blueprint.route("/_index/") def index(path): - if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous: return current_app.login_manager.unauthorized() items = g.current_wiki.get_index() @@ -187,7 +187,7 @@ def page_write(name): if not cname: return dict(error=True, message="Invalid name") - if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous(): + if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous: return dict(error=True, message="Anonymous posting not allowed"), 403 if request.method == 'POST': @@ -230,7 +230,7 @@ def page_write(name): @blueprint.route("/", defaults={'name': 'home'}) @blueprint.route("/") def page(name): - if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous(): + if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous: return current_app.login_manager.unauthorized() cname = to_canonical(name) diff --git a/realms/templates/layout.html b/realms/templates/layout.html index 4eb1717..a8ee14c 100644 --- a/realms/templates/layout.html +++ b/realms/templates/layout.html @@ -58,7 +58,7 @@ - {% if current_user.is_authenticated() %} + {% if current_user.is_authenticated %}