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

Remove unused json encoder customizations

parent 9545981a
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from babel.dates import LOCALTZ ...@@ -8,7 +8,7 @@ from babel.dates import LOCALTZ
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden
from flask_migrate import Migrate 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 .template_helper import register_template_helper
from .navbar import setup_navbar from .navbar import setup_navbar
from .csrf import bp as csrf_bp from .csrf import bp as csrf_bp
...@@ -52,7 +52,6 @@ def init_config(app: Flask, test_config): ...@@ -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 def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-statements
app = Flask(__name__, instance_relative_config=False) app = Flask(__name__, instance_relative_config=False)
app.json_encoder = SQLAlchemyJSON
init_config(app, test_config) init_config(app, test_config)
......
from collections import OrderedDict
from sqlalchemy import MetaData, event from sqlalchemy import MetaData, event
from sqlalchemy.types import TypeDecorator, Text from sqlalchemy.types import TypeDecorator, Text
from sqlalchemy.ext.mutable import MutableList from sqlalchemy.ext.mutable import MutableList
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask.json import JSONEncoder
convention = { convention = {
'ix': 'ix_%(column_0_label)s', 'ix': 'ix_%(column_0_label)s',
...@@ -48,15 +45,6 @@ def customize_db_engine(engine): ...@@ -48,15 +45,6 @@ def customize_db_engine(engine):
cursor.execute('SET NAMES utf8mb4 COLLATE utf8mb4_nopad_bin') cursor.execute('SET NAMES utf8mb4 COLLATE utf8mb4_nopad_bin')
cursor.close() 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): class CommaSeparatedList(TypeDecorator):
# For some reason TypeDecorator.process_literal_param and # For some reason TypeDecorator.process_literal_param and
# TypeEngine.python_type are abstract but not actually required # 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