)]}'
{"ceilometer/api/controllers/v2.py":[{"author":{"_account_id":7179,"name":"Brad Pokorny","email":"brad_pokorny@symantec.com","username":"bpokorny"},"change_message_id":"be3681bc00ce4c7d138aa6a87a3483340ddbe33c","unresolved":false,"context_lines":[{"line_number":521,"context_line":"                            pecan.request.headers.get(\u0027X-Project-Id\u0027))"},{"line_number":522,"context_line":"            if auth_project and auth_project !\u003d s.project_id:"},{"line_number":523,"context_line":"                # non admin user trying to cross post to another project_id"},{"line_number":524,"context_line":"                auth_msg \u003d \u0027can not post samples to other projects\u0027"},{"line_number":525,"context_line":"                raise wsme.exc.InvalidInput(\u0027project_id\u0027, s.project_id,"},{"line_number":526,"context_line":"                                            auth_msg)"},{"line_number":527,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FIpk%3D","line":524,"updated":"2013-08-06 17:10:16.000000000","message":"I agree the wsme.exc.InvalidInput instances should be localized.  I modified the one on line 707 to take advantage of the delayed translation.  The others in this file don\u0027t have entries in the ceilometer.po file, so those should probably be added as a separate change.","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"},{"author":{"_account_id":5678,"name":"John Herndon","email":"john.herndon@hp.com","username":"john-herndon"},"change_message_id":"95ebf10e7e14f7af23aca38e64e12468edfacd04","unresolved":false,"context_lines":[{"line_number":521,"context_line":"                            pecan.request.headers.get(\u0027X-Project-Id\u0027))"},{"line_number":522,"context_line":"            if auth_project and auth_project !\u003d s.project_id:"},{"line_number":523,"context_line":"                # non admin user trying to cross post to another project_id"},{"line_number":524,"context_line":"                auth_msg \u003d \u0027can not post samples to other projects\u0027"},{"line_number":525,"context_line":"                raise wsme.exc.InvalidInput(\u0027project_id\u0027, s.project_id,"},{"line_number":526,"context_line":"                                            auth_msg)"},{"line_number":527,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FMbo%3D","line":524,"updated":"2013-08-05 17:24:39.000000000","message":"shouldn\u0027t wsme.exc.InvalidInput be localized as well?","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"},{"author":{"_account_id":5678,"name":"John Herndon","email":"john.herndon@hp.com","username":"john-herndon"},"change_message_id":"42d1074fe00253fa14385f3f82b21ca85a80ee90","unresolved":false,"context_lines":[{"line_number":837,"context_line":"                                      project\u003ddata.project_id))"},{"line_number":838,"context_line":"        if len(alarms) \u003e 0:"},{"line_number":839,"context_line":"            error \u003d _(\"Alarm with that name exists\")"},{"line_number":840,"context_line":"            pecan.response.translatable_error \u003d error"},{"line_number":841,"context_line":"            raise wsme.exc.ClientSideError(error)"},{"line_number":842,"context_line":""},{"line_number":843,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FL8E%3D","line":840,"updated":"2013-08-05 19:08:54.000000000","message":"Can this be done in a decorator or something?","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"},{"author":{"_account_id":7179,"name":"Brad Pokorny","email":"brad_pokorny@symantec.com","username":"bpokorny"},"change_message_id":"eb48103f61569812d1bec57da72254b15fb4f88d","unresolved":false,"context_lines":[{"line_number":837,"context_line":"                                      project\u003ddata.project_id))"},{"line_number":838,"context_line":"        if len(alarms) \u003e 0:"},{"line_number":839,"context_line":"            error \u003d _(\"Alarm with that name exists\")"},{"line_number":840,"context_line":"            pecan.response.translatable_error \u003d error"},{"line_number":841,"context_line":"            raise wsme.exc.ClientSideError(error)"},{"line_number":842,"context_line":""},{"line_number":843,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FAgU%3D","line":840,"in_reply_to":"AAAAQn%2F%2FIkY%3D","updated":"2013-08-08 15:10:29.000000000","message":"I like this idea, as it would keep the code cleaner.  So I did some testing with it but ran into some complications.\n\n1. The wsexpose function in wsmeext \"consumes\" any exceptions it catches and only returns information about exceptions as python objects.  So the except block of localize_exceptions never gets called.\n\n2. I next tried putting @localize_exceptions under @wsme_peca.wsexpose in the code, since decorators get resolved starting from the one closest to the def statement, moving upwards.  But then I got errors like this:\n\n  File \"/opt/stack/ceilometer/.tox/py27/local/lib/python2.7/site-packages/wsme/api.py\", line 120, in set_arg_types\n    if args[0] \u003d\u003d \u0027self\u0027:\nIndexError: list index out of range\n\nWhich I think is a result of wsexpose assuming it\u0027s going to be the first decorator.  I tried a bunch of other ways to structure localize_exceptions as well (passing the same variables to localize_exceptions as the variables that go to wsexpose, for example), but none worked.\n\nSo I haven\u0027t found a way to make this work, as localize_exceptions can\u0027t be before or after wsexpose without making changes to wsexpose.","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"},{"author":{"_account_id":5678,"name":"John Herndon","email":"john.herndon@hp.com","username":"john-herndon"},"change_message_id":"834ee1527d8105678397aef206519444a0d0be17","unresolved":false,"context_lines":[{"line_number":837,"context_line":"                                      project\u003ddata.project_id))"},{"line_number":838,"context_line":"        if len(alarms) \u003e 0:"},{"line_number":839,"context_line":"            error \u003d _(\"Alarm with that name exists\")"},{"line_number":840,"context_line":"            pecan.response.translatable_error \u003d error"},{"line_number":841,"context_line":"            raise wsme.exc.ClientSideError(error)"},{"line_number":842,"context_line":""},{"line_number":843,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FIkY%3D","line":840,"in_reply_to":"AAAAQn%2F%2FIpc%3D","updated":"2013-08-06 17:29:48.000000000","message":"What about something like this?\n\ndef localize_exceptions(func):\n\n    @functools.wraps(func)\n    def wrapped(*args, **kwargs):\n        try:\n            return func(*args, **kwargs)\n        except Exception as e:\n            if hasattr(e, \u0027message\u0027):\n                pecan.response.translatable_error \u003d e.message\n            raise e\n\n    return wrapped\n\nYou can then decorate your entry points like this:\n@localize_exception\n@wsme_peca.wsexpose(blah blah...)\ndef get(.....).....\n\nI tried doing that here, haven\u0027t gotten any comments on it yet:\nhttps://review.openstack.org/#/c/40248/4/ceilometer/api/controllers/v2.py\n\n\nWhat do you think, will it work?","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"},{"author":{"_account_id":7179,"name":"Brad Pokorny","email":"brad_pokorny@symantec.com","username":"bpokorny"},"change_message_id":"be3681bc00ce4c7d138aa6a87a3483340ddbe33c","unresolved":false,"context_lines":[{"line_number":837,"context_line":"                                      project\u003ddata.project_id))"},{"line_number":838,"context_line":"        if len(alarms) \u003e 0:"},{"line_number":839,"context_line":"            error \u003d _(\"Alarm with that name exists\")"},{"line_number":840,"context_line":"            pecan.response.translatable_error \u003d error"},{"line_number":841,"context_line":"            raise wsme.exc.ClientSideError(error)"},{"line_number":842,"context_line":""},{"line_number":843,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAQn%2F%2FIpc%3D","line":840,"in_reply_to":"AAAAQn%2F%2FL8E%3D","updated":"2013-08-06 17:10:16.000000000","message":"I thought about using a decorator on the response object to \"add on\" a translatable_error member.  I\u0027m not very familiar with decorators in python, but the decorator class could look something like this:\n\nclass response_decorator(object):\n    def __init__(self):\n        self.translatable_error \u003d None\n\nBut then to attach the decorator to the response object, I\u0027d have to modify the Response class definition in webob.response to look something like this to use the decorator:\n\n@response_decorator\nclass Response(object):\n\nWhich would be adding Ceilometer-specific code to webob, and that\u0027s probably not a good thing for webob.\n\nIs there an easier way to use a decorator to do this that I\u0027m missing?","commit_id":"3114b1f81ea65cceb8f4eb6f85368e226cdf051a"}],"ceilometer/api/middleware.py":[{"author":{"_account_id":1669,"name":"Julien Danjou","display_name":"jd","email":"julien@danjou.info","username":"jdanjou"},"change_message_id":"861256013f2a226406c9c456b8027efcbea6cd15","unresolved":false,"context_lines":[{"line_number":76,"context_line":"        if (state[\u0027status_code\u0027] / 100) not in (2, 3):"},{"line_number":77,"context_line":"            req \u003d webob.Request(environ)"},{"line_number":78,"context_line":"            # This is brittle - is there a better way to find the array index"},{"line_number":79,"context_line":"            # that holds the TranslationHook?"},{"line_number":80,"context_line":"            error \u003d self.app.hooks[3].local_error.translatable_error"},{"line_number":81,"context_line":"            user_locale \u003d req.accept_language.best_match("},{"line_number":82,"context_line":"                gettextutils.get_available_languages(\u0027ceilometer\u0027),"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAQn%2F%2FNfs%3D","line":79,"updated":"2013-08-05 12:49:22.000000000","message":"Iterate over self.app.hooks until you find one that has the right class via isinstance()?","commit_id":"fe030b1eadeecf774482ece2f1c803be82f21d34"},{"author":{"_account_id":7179,"name":"Brad Pokorny","email":"brad_pokorny@symantec.com","username":"bpokorny"},"change_message_id":"d161abb6361dd79ed3fd260a2a75e9e426106182","unresolved":false,"context_lines":[{"line_number":76,"context_line":"        if (state[\u0027status_code\u0027] / 100) not in (2, 3):"},{"line_number":77,"context_line":"            req \u003d webob.Request(environ)"},{"line_number":78,"context_line":"            # This is brittle - is there a better way to find the array index"},{"line_number":79,"context_line":"            # that holds the TranslationHook?"},{"line_number":80,"context_line":"            error \u003d self.app.hooks[3].local_error.translatable_error"},{"line_number":81,"context_line":"            user_locale \u003d req.accept_language.best_match("},{"line_number":82,"context_line":"                gettextutils.get_available_languages(\u0027ceilometer\u0027),"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAQn%2F%2FMwA%3D","line":79,"updated":"2013-08-05 15:56:26.000000000","message":"Thanks for the suggestion.  Done.","commit_id":"fe030b1eadeecf774482ece2f1c803be82f21d34"}]}
