-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do not log a warning for empty responses #69
Conversation
if a text/html response does not contain any data (eg empty page for an ajax request) we do not log a warning that no csrf token could be added this fixes #15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plone/protect/auto.py
Outdated
if isinstance(result, list): | ||
# do not parse empty strings to omit warning log message | ||
if len(result) == 1: | ||
if result[0].strip() == u'': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simplify this to if not result[0].strip(): return None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @mauritsvanrees!
i was not sure what types of data structures can possibly be handed over to a transform's transform
method.
if it is just either repoze.xmliter.serializer.XMLSerializer
or a list containing one string, your simplification is fine.
if the list can possibly be empty we'd need to catch an IndexError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my simplification I only meant that one line: instead of if X == u''
do if not X
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I am not quite sure what structures can end up in here either.
thanks for your clarifications @mauritsvanrees. i simplified the if statements and started the tests |
should be ready to merge @mauritsvanrees :-) |
Merged. Thank you! |
if a text/html response does not contain any data (eg empty page for an ajax request)
we do not log a warning that no csrf token could be added
this fixes #15
not sure if the tests actually add value since i did not find a way to check no warning message is logged.