Skip to content

Commit

Permalink
Switching to DefaultJSONProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Aug 21, 2024
1 parent 3664593 commit df71d70
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 29 deletions.
6 changes: 3 additions & 3 deletions patientsearch/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
session,
send_from_directory,
)
from json import JSONEncoder
from flask.json.provider import DefaultJSONProvider
import jwt
import requests
from werkzeug.exceptions import Unauthorized, Forbidden
Expand Down Expand Up @@ -145,11 +145,11 @@ def config_settings(config_key):
"""Non-secret application settings"""

# workaround no JSON representation for datetime.timedelta
class CustomJSONEncoder(JSONEncoder):
class CustomJSONProvider(DefaultJSONProvider):
def default(self, obj):
return str(obj)

current_app.json_encoder = CustomJSONEncoder
current_app.json = CustomJSONProvider

# return selective keys - not all can be be viewed by users, e.g.secret key
blacklist = ("SECRET", "KEY", "TOKEN", "CREDENTIALS")
Expand Down
91 changes: 78 additions & 13 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,88 @@
#
# pip-compile --extra=dev --output-file=requirements.dev.txt setup.cfg
#
--requirement requirements.txt

async-timeout==4.0.3
# via redis
blinker==1.8.2
# via flask
cachelib==0.13.0
# via flask-session
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via flask
exceptiongroup==1.2.2
# via pytest
flask==3.0.3
# via
# flask-jwt-extended
# flask-session
# patientsearch (setup.cfg)
# pytest-flask
flask-jwt-extended==4.6.0
# via patientsearch (setup.cfg)
flask-session==0.8.0
# via patientsearch (setup.cfg)
gunicorn==22.0.0
# via patientsearch (setup.cfg)
idna==3.7
# via requests
importlib-metadata==8.2.0
# via flask
iniconfig==2.0.0
# via pytest
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
# via flask
jmespath==1.0.1
# via patientsearch (setup.cfg)
markupsafe==2.1.5
# via
# jinja2
# werkzeug
msgspec==0.18.6
# via flask-session
packaging==24.1
# via
# gunicorn
# pytest
pluggy==1.0.0
pluggy==1.5.0
# via pytest
pytest-datadir==1.3.1
# via patientsearch (setup.py)
pytest-flask==1.2.0
# via patientsearch (setup.py)
pytest-mock==3.6.1
# via patientsearch (setup.py)
pytest==6.2.5
# via patientsearch (setup.py), pytest-datadir, pytest-mock
toml==0.10.2
# via pytest
pyjwt==2.8.0
# via flask-jwt-extended
pytest==8.3.2
# via
# patientsearch (setup.cfg)
# pytest-datadir
# pytest-flask
# pytest-mock
pytest-datadir==1.5.0
# via patientsearch (setup.cfg)
pytest-flask==1.3.0
# via patientsearch (setup.cfg)
pytest-mock==3.14.0
# via patientsearch (setup.cfg)
python-json-logger==2.0.7
# via patientsearch (setup.cfg)
redis==5.0.7
# via
# patientsearch (setup.cfg)
# redis-dict
redis-dict==2.5.0
# via patientsearch (setup.cfg)
requests==2.32.3
# via patientsearch (setup.cfg)
tomli==2.0.1
# via pytest
urllib3==2.2.2
# via requests
werkzeug==3.0.3
# via
# flask
# flask-jwt-extended
# pytest-flask
zipp==3.19.2
# via importlib-metadata
22 changes: 9 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via flask
flask==2.0.1
flask==3.0.3
# via
# flask-jwt-extended
# flask-session
# patientsearch (setup.py)
flask-jwt-extended==3.24.1
# via patientsearch (setup.py)
flask-session==0.3.2
# via patientsearch (setup.py)
# pin to last hash of master, to remove requirement of freestanding JSON config file
git+https://github.com/uwcirg/flask-oidc.git@ed4eb20#egg=flask-oidc
# patientsearch (setup.cfg)
flask-jwt-extended==4.6.0
# via patientsearch (setup.cfg)
flask-session==0.8.0
# via patientsearch (setup.cfg)
gunicorn==22.0.0
# via patientsearch (setup.cfg)
idna==3.7
# via requests
importlib-metadata==8.2.0
# via flask
itsdangerous==2.0.1
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
# via flask
Expand All @@ -47,7 +45,7 @@ msgspec==0.18.6
# via flask-session
packaging==24.1
# via gunicorn
pyjwt==1.7.1
pyjwt==2.8.0
# via flask-jwt-extended
python-json-logger==2.0.7
# via patientsearch (setup.cfg)
Expand All @@ -61,11 +59,9 @@ requests==2.32.3
# via patientsearch (setup.cfg)
urllib3==2.2.2
# via requests
werkzeug==2.0.1
werkzeug==3.0.3
# via
# flask
# flask-jwt-extended
zipp==3.19.2
# via importlib-metadata
six==1.15.0
# via flask-jwt-extended

0 comments on commit df71d70

Please sign in to comment.