diff --git a/uffd/__init__.py b/uffd/__init__.py index bfb32ff24ead4c1a3738151d36cedd113fd31eef..b669c0057ab7de84694da0d18edd9b4caee55abf 100644 --- a/uffd/__init__.py +++ b/uffd/__init__.py @@ -8,7 +8,7 @@ from babel.dates import LOCALTZ from werkzeug.exceptions import Forbidden from flask_migrate import Migrate -from .database import db, SQLAlchemyJSON, customize_db_engine +from .database import db, customize_db_engine from .template_helper import register_template_helper from .navbar import setup_navbar from .csrf import bp as csrf_bp @@ -52,7 +52,6 @@ def init_config(app: Flask, test_config): def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-statements app = Flask(__name__, instance_relative_config=False) - app.json_encoder = SQLAlchemyJSON init_config(app, test_config) diff --git a/uffd/database.py b/uffd/database.py index 38ed8951d1683f33f352d8ea68d00928eed3d527..b0e11cc72f3b211da45a47e03158636bf466f668 100644 --- a/uffd/database.py +++ b/uffd/database.py @@ -1,10 +1,7 @@ -from collections import OrderedDict - from sqlalchemy import MetaData, event from sqlalchemy.types import TypeDecorator, Text from sqlalchemy.ext.mutable import MutableList from flask_sqlalchemy import SQLAlchemy -from flask.json import JSONEncoder convention = { 'ix': 'ix_%(column_0_label)s', @@ -48,15 +45,6 @@ def customize_db_engine(engine): cursor.execute('SET NAMES utf8mb4 COLLATE utf8mb4_nopad_bin') cursor.close() -class SQLAlchemyJSON(JSONEncoder): - def default(self, o): - if isinstance(o, db.Model): - result = OrderedDict() - for key in o.__mapper__.c.keys(): - result[key] = getattr(o, key) - return result - return JSONEncoder.default(self, o) - class CommaSeparatedList(TypeDecorator): # For some reason TypeDecorator.process_literal_param and # TypeEngine.python_type are abstract but not actually required