)]}'
{"cinder/utils.py":[{"author":{"_account_id":13157,"name":"Zhao Chao","email":"zhaochao1984@gmail.com","username":"zhaochao"},"change_message_id":"ff12d90a69e02bc76746d93daca6dc9aa67d8035","unresolved":false,"context_lines":[{"line_number":654,"context_line":"        raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":655,"context_line":""},{"line_number":656,"context_line":""},{"line_number":657,"context_line":"def remove_name_description_leading_trailing_spaces(body):"},{"line_number":658,"context_line":"    for attribute in [\u0027name\u0027, \u0027description\u0027,"},{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_ae575cca","line":657,"updated":"2018-01-16 09:04:40.000000000","message":"This function is almost identical to validate_name_and_description, why not just adding that one back to backup and snapshot apis?","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"},{"author":{"_account_id":9535,"name":"Gorka Eguileor","email":"geguileo@redhat.com","username":"Gorka"},"change_message_id":"eed3ae1b934fe94ac95706f087a7535e031f40ba","unresolved":false,"context_lines":[{"line_number":654,"context_line":"        raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":655,"context_line":""},{"line_number":656,"context_line":""},{"line_number":657,"context_line":"def remove_name_description_leading_trailing_spaces(body):"},{"line_number":658,"context_line":"    for attribute in [\u0027name\u0027, \u0027description\u0027,"},{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_909956c5","line":657,"in_reply_to":"7f96bb07_44aa3771","updated":"2018-01-16 13:33:38.000000000","message":"I would prefer adding an optional parameter to validate_name_and_description, something like check_length that defaults to True, that way we can just use that one.\n\n    @staticmethod\n    def validate_name_and_description(body, check_length\u003dTrue):\n        for attribute in [\u0027name\u0027, \u0027description\u0027,\n                          \u0027display_name\u0027, \u0027display_description\u0027]:\n            value \u003d body.get(attribute)\n            if value is not None:\n                if isinstance(value, six.string_types):\n                    body[attribute] \u003d value.strip()\n                if not check_length:\n                    return\n                try:\n                    utils.check_string_length(body[attribute], attribute,\n                                              min_length\u003d0, max_length\u003d255)\n                except exception.InvalidInput as error:\n                    raise webob.exc.HTTPBadRequest(explanation\u003derror.msg)\n\n\nIn any case this method should not be in utils, it should be part of the Controller class.","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"},{"author":{"_account_id":13157,"name":"Zhao Chao","email":"zhaochao1984@gmail.com","username":"zhaochao"},"change_message_id":"261ca391068e2f428d5ff0e5d5195353e0dc939d","unresolved":false,"context_lines":[{"line_number":654,"context_line":"        raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":655,"context_line":""},{"line_number":656,"context_line":""},{"line_number":657,"context_line":"def remove_name_description_leading_trailing_spaces(body):"},{"line_number":658,"context_line":"    for attribute in [\u0027name\u0027, \u0027description\u0027,"},{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_44aa3771","line":657,"in_reply_to":"7f96bb07_4e29f898","updated":"2018-01-16 10:09:28.000000000","message":"As explained in IRC, a note about the removal of validate_name_and_description would be good.","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"},{"author":{"_account_id":13157,"name":"Zhao Chao","email":"zhaochao1984@gmail.com","username":"zhaochao"},"change_message_id":"a309ea9f9a76102ea46b19418886c9d796ba3abc","unresolved":false,"context_lines":[{"line_number":654,"context_line":"        raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":655,"context_line":""},{"line_number":656,"context_line":""},{"line_number":657,"context_line":"def remove_name_description_leading_trailing_spaces(body):"},{"line_number":658,"context_line":"    for attribute in [\u0027name\u0027, \u0027description\u0027,"},{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_d18120fd","line":657,"in_reply_to":"7f96bb07_909956c5","updated":"2018-01-16 14:57:37.000000000","message":"Yes, making validate_name_and_description working with the already migrated api is straightforward and much simpler. I was thinking that as api validation will migrate to jsonschema, so removing functions like validate_name_and_description and validate_string_lenght makes sense. I agree we\u0027d better do do this kind of operations inside the Controller class.","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"},{"author":{"_account_id":24645,"name":"Pooja Jadhav","email":"pooja.jadhav@nttdata.com","username":"poojajadhav"},"change_message_id":"f457d5ec2810f647bdd334a1155e47efcbc5aeb8","unresolved":false,"context_lines":[{"line_number":654,"context_line":"        raise exception.InvalidInput(reason\u003dmsg)"},{"line_number":655,"context_line":""},{"line_number":656,"context_line":""},{"line_number":657,"context_line":"def remove_name_description_leading_trailing_spaces(body):"},{"line_number":658,"context_line":"    for attribute in [\u0027name\u0027, \u0027description\u0027,"},{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_4e29f898","line":657,"in_reply_to":"7f96bb07_ae575cca","updated":"2018-01-16 09:21:44.000000000","message":"validate_name_and_description() method is checking for string \u0027type\u0027, \u0027minLength\u0027 and \u0027maxLength\u0027 as well along with the stripping the extra white spaces from the string. JsonSchema validation is already doing that kind validation at schema level. remove_name_description_leading_trailing_spaces() method is written for removing leading and trailing spaces only.","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"},{"author":{"_account_id":4523,"name":"Eric Harney","email":"eharney@redhat.com","username":"eharney"},"change_message_id":"a440f315a3ac0ec806994d74954fbc54c804f9e2","unresolved":false,"context_lines":[{"line_number":659,"context_line":"                      \u0027display_name\u0027, \u0027display_description\u0027]:"},{"line_number":660,"context_line":"        value \u003d body.get(attribute)"},{"line_number":661,"context_line":"        if value is not None:"},{"line_number":662,"context_line":"            body[attribute] \u003d value.strip()"},{"line_number":663,"context_line":""},{"line_number":664,"context_line":""},{"line_number":665,"context_line":"_visible_admin_metadata_keys \u003d [\u0027readonly\u0027, \u0027attached_mode\u0027]"}],"source_content_type":"text/x-python","patch_set":1,"id":"7f96bb07_31dac44b","line":662,"updated":"2018-01-16 14:52:18.000000000","message":"I don\u0027t think value.strip() is sufficient here -- in python3 it will strip unicode whitespace characters like \"em quad U+2001\" but python2 won\u0027t.\n\nThis method needs to be examined closely with unit tests to make sure we don\u0027t end up with an API difference depending on whether Cinder is running on python 2 or python 3.","commit_id":"608b8ec3785bc0da4e37f7711d68346931944582"}]}
