Skip to content

Commit

Permalink
Added new version of deepcopy handling
Browse files Browse the repository at this point in the history
  • Loading branch information
OdinsPlasmaRifle committed Feb 22, 2021
1 parent babfd36 commit a60d23f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions drf_request_logging/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def get_body(self, body):
def get_response(self, response):
"""
Get the response body with sensitive values masked.
"""
res = deepcopy(response).render()
Expects a rendered response.
"""
res = deepcopy(response)
res.data = mask_and_clean_response_data(res.data)
return res

Expand Down Expand Up @@ -172,8 +173,9 @@ def finalize_response(self, request, response, *args, **kwargs):
# Add new information about the request.
self.new_request.user = user
self.new_request.status_code = response.status_code
# Get a stored response to save on the database.
stored_response = self.get_response(response)
# Get a rendered and stored response to save on the database.
rendered_response = response.render()
stored_response = self.get_response(rendered_response)
# TODO : Look into saving this as rendered data/text.
# Pickle messes with the deepcopy functionality on models.
self.new_request.response = pickle.dumps(stored_response)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup


VERSION = '0.0.14'
VERSION = '0.0.15'

with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
README = readme.read()
Expand Down

0 comments on commit a60d23f

Please sign in to comment.