diff --git a/cycledash/__init__.py b/cycledash/__init__.py index 021257f..d3f9829 100644 --- a/cycledash/__init__.py +++ b/cycledash/__init__.py @@ -1,7 +1,9 @@ from flask import Flask, jsonify, request, make_response, current_app import flask.json from flask_sqlalchemy import SQLAlchemy -from flask.ext import restful, login, bcrypt +import flask_restful as restful +import flast_login as login +import flask_bcrypt as bcrypt import humanize import logging import sys diff --git a/cycledash/api/__init__.py b/cycledash/api/__init__.py index 93a081e..f174139 100644 --- a/cycledash/api/__init__.py +++ b/cycledash/api/__init__.py @@ -1,7 +1,7 @@ from collections import OrderedDict from flask import request -import flask.ext.restful -from flask.ext.login import current_user +import flask_restful +from flask_login import current_user import functools import voluptuous @@ -10,7 +10,7 @@ from cycledash.helpers import prepare_request_data, camelcase_dict -class Resource(flask.ext.restful.Resource, object): +class Resource(flask_restful.Resource, object): """Extends Resource by adding an authentication check for basic auth or valid session cokie. """ @@ -33,7 +33,7 @@ def dispatch_request(self, *args, **kwargs): authorized = True if not authorized: auth_msg = 'Correct username/password required.' - return flask.ext.restful.abort(401, message=auth_msg) + return flask_restful.abort(401, message=auth_msg) return super(Resource, self).dispatch_request(*args, **kwargs) @@ -88,12 +88,12 @@ def decorator(f): @functools.wraps(f) def wrapper(*args, **kwargs): if not (request.json or request.data or request.form): - flask.ext.restful.abort(400, message='Validation error.', + flask_restful.abort(400, message='Validation error.', errors=['No data provided.']) try: data = schema(prepare_request_data(request)) except voluptuous.MultipleInvalid as err: - flask.ext.restful.abort(400, + flask_restful.abort(400, message='Validation error.', errors=[str(e) for e in err.errors]) setattr(request, 'validated_body', data) diff --git a/cycledash/api/bams.py b/cycledash/api/bams.py index 1009643..a9ea9bc 100644 --- a/cycledash/api/bams.py +++ b/cycledash/api/bams.py @@ -1,6 +1,6 @@ """Defines the API for BAMs.""" from flask import request -from flask.ext.restful import abort, fields +from flask_restful import abort, fields from sqlalchemy import select, desc import voluptuous from voluptuous import Schema, Required, Any, Exclusive, Coerce diff --git a/cycledash/api/comments.py b/cycledash/api/comments.py index 93a7379..d9f2fdd 100644 --- a/cycledash/api/comments.py +++ b/cycledash/api/comments.py @@ -1,8 +1,8 @@ """API for user comments.""" from collections import defaultdict from flask import jsonify, request -from flask.ext.restful import abort, fields -from flask.ext.login import current_user +from flask_restful import abort, fields +from flask_login import current_user from sqlalchemy import select, func, desc from voluptuous import Any, Required, Coerce, Schema diff --git a/cycledash/api/genotypes.py b/cycledash/api/genotypes.py index 1826a8a..dbf3218 100644 --- a/cycledash/api/genotypes.py +++ b/cycledash/api/genotypes.py @@ -3,7 +3,7 @@ import copy import json from flask import request -import flask.ext.restful as restful +import flask_restful as restful from plone.memoize import forever from sqlalchemy import (select, func, types, cast, join, outerjoin, asc, desc, and_, Integer, Float, String, distinct) diff --git a/cycledash/api/projects.py b/cycledash/api/projects.py index 622292f..99f5be7 100644 --- a/cycledash/api/projects.py +++ b/cycledash/api/projects.py @@ -1,6 +1,6 @@ """Defines the API for Projects.""" from flask import request, redirect, jsonify, url_for, render_template -from flask.ext.restful import fields, abort +from flask_restful import fields, abort from sqlalchemy import exc, select, func, desc import voluptuous from voluptuous import Schema, Required, Any diff --git a/cycledash/api/runs.py b/cycledash/api/runs.py index 2a72957..eae501e 100644 --- a/cycledash/api/runs.py +++ b/cycledash/api/runs.py @@ -1,6 +1,6 @@ import datetime from flask import request -from flask.ext.restful import abort, fields +from flask_restful import abort, fields from sqlalchemy import select, desc, func import voluptuous from voluptuous import Schema, Any, Required, Exclusive, Coerce diff --git a/cycledash/api/tasks.py b/cycledash/api/tasks.py index b0ffff3..45edd48 100644 --- a/cycledash/api/tasks.py +++ b/cycledash/api/tasks.py @@ -1,7 +1,7 @@ """Methods for working with Celery task states.""" from collections import defaultdict from sqlalchemy import select -from flask.ext.restful import abort, fields +from flask_restful import abort, fields from voluptuous import Schema, Any from common.helpers import tables diff --git a/cycledash/auth.py b/cycledash/auth.py index a0759c8..13ce113 100644 --- a/cycledash/auth.py +++ b/cycledash/auth.py @@ -1,6 +1,6 @@ """Module to manage user authentication and identification.""" from flask import request, redirect, render_template -from flask.ext.login import login_user, logout_user +from flask_login import login_user, logout_user from sqlalchemy import exc import voluptuous import base64 diff --git a/cycledash/helpers.py b/cycledash/helpers.py index 9c128dd..145f05f 100644 --- a/cycledash/helpers.py +++ b/cycledash/helpers.py @@ -9,7 +9,7 @@ from common.helpers import tables, to_epoch from flask import jsonify, request, url_for, redirect -import flask.ext.restful, flask.ext.restful.fields +import flask_restful, flask_restful.fields import voluptuous from werkzeug.utils import secure_filename @@ -188,7 +188,7 @@ def abort_if_none_for(obj_name): def abort_if_none(obj, obj_id): """Abort request with a 404 if object is None.""" if obj is None: - flask.ext.restful.abort( + flask_restful.abort( 404, message='No {} with id={} found.'.format(obj_name, obj_id)) else: diff --git a/cycledash/views.py b/cycledash/views.py index 87d1868..1d671fd 100644 --- a/cycledash/views.py +++ b/cycledash/views.py @@ -3,7 +3,7 @@ import json import tempfile from flask import request, redirect, render_template, send_file, Response -from flask.ext.login import login_required +from flask_login import login_required from sqlalchemy import select, desc, exc import voluptuous diff --git a/requirements.txt b/requirements.txt index 34f24ac..f6076e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ requests==2.3.0 voluptuous==0.8.7 wsgiref==0.1.2 psycopg2==2.5.4 -pylint==1.4.1 +pylint==1.5.0 humanize==0.5.1 varcode==0.3.11 mock==1.0.1 diff --git a/tests/python/test_authentication.py b/tests/python/test_authentication.py index 449fce4..2ea11fc 100644 --- a/tests/python/test_authentication.py +++ b/tests/python/test_authentication.py @@ -1,7 +1,7 @@ """Tests to make sure authentication is present + working.""" -from flask.ext.login import login_user +from flask_login import login_user import mock import nose import nose.tools as asserts diff --git a/tests/python/test_views.py b/tests/python/test_views.py index 8dc244a..c1b1d93 100644 --- a/tests/python/test_views.py +++ b/tests/python/test_views.py @@ -1,5 +1,5 @@ """Test rendered views of Cycledash.""" -from flask.ext.login import login_user +from flask_login import login_user import mock import nose import nose.tools as asserts