django-cookie-consent
django-cookie-consent copied to clipboard
Catch Unexpected Errors Part 2
Helps with #26 and prevents unexpected errors. Was not sure how to solve it otherwise. Part of the other pull request I made.
Hi @9mido , perhaps focusing on the get_decline_cookie_groups_cookie_string
is not the best approach, as it mainly call other functions.
The problem ultimately lies with the get_cookie_dict_from_request
from utls.py
So, maybe something like this?
def get_cookie_dict_from_request(request):
if hasattr(request, 'COOKIES'):
cookie_str = request.COOKIES.get(settings.COOKIE_CONSENT_NAME)
else:
return
return parse_cookie_str(cookie_str)
It's a bit more focused than your PR, but not something I would be comfortable with as I still don't understand why the templatetag is collecting a string request...
Also I don't know how to write a test for it. :/
I agree with @bmihelac and @MrCordeiro that this approach isn't desired, as it hides the actual underlying problem. I will close this PR to clean up the repository, but leave the issue open so we can use that to further investigate what is happening.