Skip to content
Snippets Groups Projects
Commit 1ed39c8e authored by Julian's avatar Julian
Browse files

Remove unused json encoder customizations

parent 9545981a
Branches
Tags
No related merge requests found
......@@ -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)
......
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment