aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-02 08:44:14 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-02 08:44:14 +0100
commit946b1aec53faf8761f44f59e99ce21d308ab8d47 (patch)
treedc47b0a67a3254773509f2c40c611ea77ac4b40e
parentminor improvements to the home page. (diff)
downloadnewspipe-946b1aec53faf8761f44f59e99ce21d308ab8d47.tar.gz
newspipe-946b1aec53faf8761f44f59e99ce21d308ab8d47.tar.bz2
newspipe-946b1aec53faf8761f44f59e99ce21d308ab8d47.zip
Removed deprecated API.
-rw-r--r--newspipe/bootstrap.py4
-rw-r--r--newspipe/web/views/__init__.py3
-rw-r--r--newspipe/web/views/api/v3/__init__.py3
-rw-r--r--newspipe/web/views/api/v3/article.py84
-rw-r--r--newspipe/web/views/api/v3/common.py105
-rw-r--r--newspipe/web/views/api/v3/feed.py62
-rw-r--r--poetry.lock54
-rw-r--r--pyproject.toml1
8 files changed, 7 insertions, 309 deletions
diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py
index 01e38fbf..cbdbc820 100644
--- a/newspipe/bootstrap.py
+++ b/newspipe/bootstrap.py
@@ -6,7 +6,6 @@
import os
import conf
import logging
-import flask_restless
from urllib.parse import urlsplit
@@ -80,9 +79,6 @@ if not application.config["SECURITY_PASSWORD_SALT"]:
db = SQLAlchemy(application)
-# Create the Flask-Restless API manager.
-manager = flask_restless.APIManager(application, flask_sqlalchemy_db=db)
-
def populate_g():
from flask import g
diff --git a/newspipe/web/views/__init__.py b/newspipe/web/views/__init__.py
index b8b415f9..a2f7bd1c 100644
--- a/newspipe/web/views/__init__.py
+++ b/newspipe/web/views/__init__.py
@@ -1,4 +1,4 @@
-from web.views.api import v2, v3
+from web.views.api import v2
from web.views import views, home, session_mgmt
from web.views.article import article_bp, articles_bp
from web.views.feed import feed_bp, feeds_bp
@@ -13,7 +13,6 @@ __all__ = [
"home",
"session_mgmt",
"v2",
- "v3",
"article_bp",
"articles_bp",
"feed_bp",
diff --git a/newspipe/web/views/api/v3/__init__.py b/newspipe/web/views/api/v3/__init__.py
deleted file mode 100644
index 5066b0b6..00000000
--- a/newspipe/web/views/api/v3/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from web.views.api.v3 import article
-
-__all__ = ["article"]
diff --git a/newspipe/web/views/api/v3/article.py b/newspipe/web/views/api/v3/article.py
deleted file mode 100644
index 55ba3326..00000000
--- a/newspipe/web/views/api/v3/article.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Newspipe - A Web based news aggregator.
-# Copyright (C) 2010-2020 Cédric Bonhomme - https://www.cedricbonhomme.org
-#
-# For more information : http://gitlab.com/newspipe/newspipe
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>
-
-__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.1 $"
-__date__ = "$Date: 2016/04/29 $"
-__revision__ = "$Date: 2016/04/29 $"
-__copyright__ = "Copyright (c) Cedric Bonhomme"
-__license__ = "GPLv3"
-
-from flask_login import current_user
-from werkzeug.exceptions import NotFound
-from flask_restless import ProcessingException
-from web import models
-from bootstrap import application, manager
-from web.controllers import ArticleController, FeedController
-from web.views.api.v3.common import AbstractProcessor
-from web.views.api.v3.common import url_prefix, auth_func
-
-
-class ArticleProcessor(AbstractProcessor):
- """Concrete processors for the Article Web service.
- """
-
- def get_single_preprocessor(self, instance_id=None, **kw):
- try:
- article = ArticleController(current_user.id).get(id=instance_id)
- except NotFound:
- raise ProcessingException(description="No such article.", code=404)
- self.is_authorized(current_user, article)
-
- def post_preprocessor(self, data=None, **kw):
- data["user_id"] = current_user.id
-
- try:
- feed = FeedController(current_user.id).get(id=data["feed_id"])
- except NotFound:
- raise ProcessingException(description="No such feed.", code=404)
- self.is_authorized(current_user, feed)
-
- data["category_id"] = feed.category_id
-
- def delete_preprocessor(self, instance_id=None, **kw):
- try:
- article = ArticleController(current_user.id).get(id=instance_id)
- except NotFound:
- raise ProcessingException(description="No such article.", code=404)
- self.is_authorized(current_user, article)
-
-
-article_processor = ArticleProcessor()
-
-blueprint_article = manager.create_api_blueprint(
- models.Article,
- url_prefix=url_prefix,
- methods=["GET", "POST", "PUT", "DELETE"],
- preprocessors=dict(
- GET_SINGLE=[auth_func, article_processor.get_single_preprocessor],
- GET_MANY=[auth_func, article_processor.get_many_preprocessor],
- POST=[auth_func, article_processor.post_preprocessor],
- PUT_SINGLE=[auth_func, article_processor.put_single_preprocessor],
- PUT_MANY=[auth_func, article_processor.put_many_preprocessor],
- DELETE=[auth_func, article_processor.delete_preprocessor],
- ),
-)
-application.register_blueprint(blueprint_article)
diff --git a/newspipe/web/views/api/v3/common.py b/newspipe/web/views/api/v3/common.py
deleted file mode 100644
index bf49bff5..00000000
--- a/newspipe/web/views/api/v3/common.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Newspipe - A Web based news aggregator.
-# Copyright (C) 2010-2020 Cédric Bonhomme - https://www.cedricbonhomme.org
-#
-# For more information : http://gitlab.com/newspipe/newspipe
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>
-
-__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.1 $"
-__date__ = "$Date: 2016/04/29 $"
-__revision__ = "$Date: 2016/04/29 $"
-__copyright__ = "Copyright (c) Cedric Bonhomme"
-__license__ = "GPLv3"
-
-from flask import request
-from flask_login import current_user
-from flask_restless import ProcessingException
-from werkzeug.exceptions import NotFound
-from web.controllers import ArticleController, UserController
-from web.views.common import login_user_bundle
-
-url_prefix = "/api/v3"
-
-
-def auth_func(*args, **kw):
- if request.authorization:
- ucontr = UserController()
- try:
- user = ucontr.get(nickname=request.authorization.username)
- except NotFound:
- raise ProcessingException("Couldn't authenticate your user", code=401)
- if not ucontr.check_password(user, request.authorization.password):
- raise ProcessingException("Couldn't authenticate your user", code=401)
- if not user.is_active:
- raise ProcessingException("User is deactivated", code=401)
- login_user_bundle(user)
- if not current_user.is_authenticated:
- raise ProcessingException(description="Not authenticated!", code=401)
-
-
-class AbstractProcessor:
- """Abstract processors for the Web services.
- """
-
- def is_authorized(self, user, obj):
- if user.id != obj.user_id:
- raise ProcessingException(description="Not Authorized", code=401)
-
- def get_single_preprocessor(self, instance_id=None, **kw):
- # Check if the user is authorized to modify the specified
- # instance of the model.
- pass
-
- def get_many_preprocessor(self, search_params=None, **kw):
- """Accepts a single argument, `search_params`, which is a dictionary
- containing the search parameters for the request.
- """
- filt = dict(name="user_id", op="eq", val=current_user.id)
-
- # Check if there are any filters there already.
- if "filters" not in search_params:
- search_params["filters"] = []
-
- search_params["filters"].append(filt)
-
- def post_preprocessor(self, data=None, **kw):
- pass
-
- def put_single_preprocessor(instance_id=None, data=None, **kw):
- """Accepts two arguments, `instance_id`, the primary key of the
- instance of the model to patch, and `data`, the dictionary of fields
- to change on the instance.
- """
- pass
-
- def put_many_preprocessor(search_params=None, data=None, **kw):
- """Accepts two arguments: `search_params`, which is a dictionary
- containing the search parameters for the request, and `data`, which
- is a dictionary representing the fields to change on the matching
- instances and the values to which they will be set.
- """
- filt = dict(name="user_id", op="eq", val=current_user.id)
-
- # Check if there are any filters there already.
- if "filters" not in search_params:
- search_params["filters"] = []
-
- search_params["filters"].append(filt)
-
- def delete_preprocessor(self, instance_id=None, **kw):
- pass
diff --git a/newspipe/web/views/api/v3/feed.py b/newspipe/web/views/api/v3/feed.py
deleted file mode 100644
index fffbf40d..00000000
--- a/newspipe/web/views/api/v3/feed.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Newspipe - A Web based news aggregator.
-# Copyright (C) 2010-2020 Cédric Bonhomme - https://www.cedricbonhomme.org
-#
-# For more information : http://gitlab.com/newspipe/newspipe
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>
-
-__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.1 $"
-__date__ = "$Date: 2016/04/29 $"
-__revision__ = "$Date: 2016/04/29 $"
-__copyright__ = "Copyright (c) Cedric Bonhomme"
-__license__ = "GPLv3"
-
-from flask_login import current_user
-from web import models
-from bootstrap import application, manager
-from web.controllers import FeedController
-from web.views.api.v3.common import AbstractProcessor
-from web.views.api.v3.common import url_prefix, auth_func
-
-
-class FeedProcessor(AbstractProcessor):
- """Concrete processors for the Feed Web service.
- """
-
- def get_single_preprocessor(self, instance_id=None, **kw):
- # Check if the user is authorized to modify the specified
- # instance of the model.
- feed = FeedController(current_user.id).get(id=instance_id)
- self.is_authorized(current_user, feed)
-
-
-feed_processor = FeedProcessor()
-
-blueprint_feed = manager.create_api_blueprint(
- models.Feed,
- url_prefix=url_prefix,
- methods=["GET", "POST", "PUT", "DELETE"],
- preprocessors=dict(
- GET_SINGLE=[auth_func, feed_processor.get_single_preprocessor],
- GET_MANY=[auth_func, feed_processor.get_many_preprocessor],
- PUT_SINGLE=[auth_func],
- POST=[auth_func],
- DELETE=[auth_func],
- ),
-)
-application.register_blueprint(blueprint_feed)
diff --git a/poetry.lock b/poetry.lock
index 2631e7ca..e7890909 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -22,7 +22,7 @@ description = "A database migration tool for SQLAlchemy."
name = "alembic"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
-version = "1.4.0"
+version = "1.4.1"
[package.dependencies]
Mako = "*"
@@ -225,20 +225,6 @@ docs = ["sphinx"]
[[package]]
category = "main"
-description = "A Flask extension for easy ReSTful API generation"
-name = "flask-restless"
-optional = false
-python-versions = "*"
-version = "0.17.0"
-
-[package.dependencies]
-flask = ">=0.10"
-mimerender = ">=0.5.2"
-python-dateutil = ">2.0"
-sqlalchemy = ">=0.8"
-
-[[package]]
-category = "main"
description = "Scripting support for Flask"
name = "flask-script"
optional = false
@@ -323,7 +309,7 @@ description = "A super-fast templating language that borrows the best ideas fro
name = "mako"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
-version = "1.1.1"
+version = "1.1.2"
[package.dependencies]
MarkupSafe = ">=0.9.2"
@@ -342,17 +328,6 @@ version = "1.1.1"
[[package]]
category = "main"
-description = "RESTful HTTP Content Negotiation for Flask, Bottle, web.py and webapp2 (Google App Engine)"
-name = "mimerender"
-optional = false
-python-versions = "*"
-version = "0.6.0"
-
-[package.dependencies]
-python_mimeparse = ">=0.1.4"
-
-[[package]]
-category = "main"
description = "multidict implementation"
name = "multidict"
optional = false
@@ -419,14 +394,6 @@ version = "1.0.4"
[[package]]
category = "main"
-description = "A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges."
-name = "python-mimeparse"
-optional = false
-python-versions = "*"
-version = "1.6.0"
-
-[[package]]
-category = "main"
description = "World timezone definitions, modern and historical"
name = "pytz"
optional = false
@@ -559,7 +526,7 @@ idna = ">=2.0"
multidict = ">=4.0"
[metadata]
-content-hash = "e8b3a93859c566e8f72ce498eaee7d1ff257823c60e95e064700951dd55e880a"
+content-hash = "c28c1de9afd6a173dd8ee2b84cca6353663ed5f1a3d86f2584449c0685ef7f0a"
python-versions = "^3.8"
[metadata.files]
@@ -578,7 +545,7 @@ aiohttp = [
{file = "aiohttp-3.6.2.tar.gz", hash = "sha256:259ab809ff0727d0e834ac5e8a283dc5e3e0ecc30c4d80b3cd17a4139ce1f326"},
]
alembic = [
- {file = "alembic-1.4.0.tar.gz", hash = "sha256:2df2519a5b002f881517693b95626905a39c5faf4b5a1f94de4f1441095d1d26"},
+ {file = "alembic-1.4.1.tar.gz", hash = "sha256:791a5686953c4b366d3228c5377196db2f534475bb38d26f70eb69668efd9028"},
]
aniso8601 = [
{file = "aniso8601-8.0.0-py2.py3-none-any.whl", hash = "sha256:c033f63d028b9a58e3ab0c2c7d0532ab4bfa7452bfc788fbfe3ddabd327b181a"},
@@ -647,9 +614,6 @@ flask-restful = [
{file = "Flask-RESTful-0.3.8.tar.gz", hash = "sha256:5ea9a5991abf2cb69b4aac19793faac6c032300505b325687d7c305ffaa76915"},
{file = "Flask_RESTful-0.3.8-py2.py3-none-any.whl", hash = "sha256:d891118b951921f1cec80cabb4db98ea6058a35e6404788f9e70d5b243813ec2"},
]
-flask-restless = [
- {file = "Flask-Restless-0.17.0.tar.gz", hash = "sha256:1de47fe80abd47239c9a1804e0ba5da1d23b9f40cfc26202d16bed37f178c2b6"},
-]
flask-script = [
{file = "Flask-Script-2.0.6.tar.gz", hash = "sha256:6425963d91054cfcc185807141c7314a9c5ad46325911bd24dcb489bd0161c65"},
]
@@ -703,7 +667,8 @@ lxml = [
{file = "lxml-4.5.0.tar.gz", hash = "sha256:8620ce80f50d023d414183bf90cc2576c2837b88e00bea3f33ad2630133bbb60"},
]
mako = [
- {file = "Mako-1.1.1.tar.gz", hash = "sha256:2984a6733e1d472796ceef37ad48c26f4a984bb18119bb2dbc37a44d8f6e75a4"},
+ {file = "Mako-1.1.2-py2.py3-none-any.whl", hash = "sha256:8e8b53c71c7e59f3de716b6832c4e401d903af574f6962edbbbf6ecc2a5fe6c9"},
+ {file = "Mako-1.1.2.tar.gz", hash = "sha256:3139c5d64aa5d175dbafb95027057128b5fbd05a40c53999f3905ceb53366d9d"},
]
markupsafe = [
{file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"},
@@ -740,9 +705,6 @@ markupsafe = [
{file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"},
{file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"},
]
-mimerender = [
- {file = "mimerender-0.6.0.tar.gz", hash = "sha256:e7f1377efee18c3f562cee54907a3329223c824332889fb74b745ddfd0a9b1c6"},
-]
multidict = [
{file = "multidict-4.7.5-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3"},
{file = "multidict-4.7.5-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35"},
@@ -819,10 +781,6 @@ python-editor = [
{file = "python_editor-1.0.4-py3-none-any.whl", hash = "sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d"},
{file = "python_editor-1.0.4-py3.5.egg", hash = "sha256:c3da2053dbab6b29c94e43c486ff67206eafbe7eb52dbec7390b5e2fb05aac77"},
]
-python-mimeparse = [
- {file = "python-mimeparse-1.6.0.tar.gz", hash = "sha256:76e4b03d700a641fd7761d3cd4fdbbdcd787eade1ebfac43f877016328334f78"},
- {file = "python_mimeparse-1.6.0-py2.py3-none-any.whl", hash = "sha256:a295f03ff20341491bfe4717a39cd0a8cc9afad619ba44b77e86b0ab8a2b8282"},
-]
pytz = [
{file = "pytz-2019.3-py2.py3-none-any.whl", hash = "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d"},
{file = "pytz-2019.3.tar.gz", hash = "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"},
diff --git a/pyproject.toml b/pyproject.toml
index 29c7fc5c..3047e33f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -23,7 +23,6 @@ Flask-Login = "^0.5.0"
Flask-Principal = "^0.4.0"
Flask-WTF = "^0.14.3"
Flask-RESTful = "^0.3.8"
-Flask-Restless = "^0.17.0"
Flask-paginate = "^0.5.5"
Flask-Babel = "^1.0.0"
Flask-Migrate = "^2.5.2"
bgstack15