Skip to content

Commit

Permalink
Configuring PYTHON_LEGACY UUID representation in bottle.py
Browse files Browse the repository at this point in the history
We cannot encode native uuid.UUID with UuidRepresentation.UNSPECIFIED therefore defining uuid_representation as PYTHON_LEGACY fixes the issue
Contains fix for - e-mission/e-mission-docs#856 (comment)
  • Loading branch information
swastis10 committed Mar 11, 2023
1 parent 3b456e7 commit edd8b77
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion emission/net/api/bottle.py
Expand Up @@ -14,6 +14,8 @@
"""

import sys
import bson.json_util as bju
from bson.binary import UuidRepresentation

__author__ = 'Marcel Hellkamp'
__version__ = '0.13-dev'
Expand Down Expand Up @@ -2001,7 +2003,7 @@ def wrapper(*a, **ka):

if isinstance(rv, dict):
#Attempt to serialize, raises exception on failure
json_response = dumps(rv)
json_response = bju.dumps(rv, json_options = bju.LEGACY_JSON_OPTIONS.with_options(uuid_representation= UuidRepresentation.PYTHON_LEGACY))
#Set content type only if serialization successful
response.content_type = 'application/json'
return json_response
Expand Down

0 comments on commit edd8b77

Please sign in to comment.