)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"578b01fe1271e3679dfabdfce532643ffe642ecf","unresolved":false,"context_lines":[{"line_number":16,"context_line":"backend-agnostic API definitions and the backend db ops are"},{"line_number":17,"context_line":"backend-specific and schema-agnostic partial implementations"},{"line_number":18,"context_line":"themselves, the options for implementing this were mixins or"},{"line_number":19,"context_line":"composition. This patch chooses composition."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"An implementation would choose the Idl backend ops like:"},{"line_number":22,"context_line":"from ovsdbapp.backend import ovs_idl"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":4,"id":"df140735_c56a867f","line":19,"range":{"start_line":19,"start_character":31,"end_line":19,"end_character":32},"updated":"2017-06-02 13:49:37.000000000","message":"wisely","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"}],"ovsdbapp/api.py":[{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"578b01fe1271e3679dfabdfce532643ffe642ecf","unresolved":false,"context_lines":[{"line_number":98,"context_line":"                    self._nested_txn \u003d None"},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"    def db_create(self, table, **col_values):"},{"line_number":101,"context_line":"        return self._backend.db_create(table, **col_values)"},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"    def db_destroy(self, table, record):"},{"line_number":104,"context_line":"        return self._backend.db_destroy(table, record)"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_25df023b","line":101,"range":{"start_line":101,"start_character":15,"end_line":101,"end_character":28},"updated":"2017-06-02 13:49:37.000000000","message":"If backend is not defined, shouldn\u0027t we raise NotImplementedError here? Let\u0027s say I\u0027m writing a Neutron-ovs-vsctl-like class and I forget to override a method because it\u0027s not an abstract method. I\u0027ll get AttributeError \"NoneType has no attribute db_create\" or something similar. NotImplementedError would make more sense imho.\n\nOr we could leave the API class as it was and create\n\nclass APICommonBackend(API):\n   backend \u003d None\n\n   def __init__(self):\n       if not self.backend:\n           raise AttributeError(\"backend needs to be specified\")\n\n    def db_create(...)\n        ....","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":5756,"name":"Terry Wilson","email":"twilson@redhat.com","username":"otherwiseguy"},"change_message_id":"5864bc4e14b22d80186b6300904344ac7d516067","unresolved":false,"context_lines":[{"line_number":98,"context_line":"                    self._nested_txn \u003d None"},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"    def db_create(self, table, **col_values):"},{"line_number":101,"context_line":"        return self._backend.db_create(table, **col_values)"},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"    def db_destroy(self, table, record):"},{"line_number":104,"context_line":"        return self._backend.db_destroy(table, record)"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_68682f1c","line":101,"range":{"start_line":101,"start_character":15,"end_line":101,"end_character":28},"in_reply_to":"df140735_25df023b","updated":"2017-06-02 14:53:57.000000000","message":"My original thinking was that the AttributeError which would show up as:\n\n Traceback (most recent call last):\n   File \"test.py\", line 10, in \u003cmodule\u003e\n     p.db_create(\u0027thing\u0027)\n   File \"/opt/stack/ovsdbapp/ovsdbapp/api.py\", line 101, in db_create\n     return self._backend.db_create(table, **col_values)\n AttributeError: \u0027MyApi\u0027 object has no attribute \u0027_backend\u0027\n\nwould suggest that they should add a backend as opposed to implementing their own db_*. Maybe NotImplementedError would be better? I\u0027m not completely sure. I could kind of cheat and very simply add it by just doing:\n\n @property\n def _backend(self):\n     try:\n         return self.__backend\n     except AttributeError:\n         raise NotImplementedError()\n\nwhich would give the traceback:\n Traceback (most recent call last):\n   File \"test.py\", line 10, in \u003cmodule\u003e\n     p.db_create(\u0027thing\u0027)\n   File \"/opt/stack/ovsdbapp/ovsdbapp/api.py\", line 108, in db_create\n     return self._backend.db_create(table, **col_values)\n   File \"/opt/stack/ovsdbapp/ovsdbapp/api.py\", line 71, in _backend\n     raise NotImplementedError()\n\nwhich isn\u0027t really ideal I suppose, since it raises outside of db_create. Another option would be to add a requires_backend decorator--something like:\n\n def requires_backend(f):\n     def decorated(self, *args, **kwargs):\n         try:\n             return f(self, *args, **kwargs)\n         except AttributeError:\n             if self.backend is None:\n                 raise AttributeError\n             else:\n                 raise\n     return decorated\n\nand do:\n\n @requires_backend\n def db_create(self, table, **colvalues):\n\netc. which would produce a better backtrace:\n\n Traceback (most recent call last):\n   File \"test.py\", line 10, in \u003cmodule\u003e\n     p.db_create(\u0027thing\u0027)\n   File \"/opt/stack/ovsdbapp/ovsdbapp/api.py\", line 60, in decorated\n     return f(self, *args, **kwargs)\n   File \"/opt/stack/ovsdbapp/ovsdbapp/api.py\", line 117, in db_create\n     raise NotImplementedError()\n\nThe only issue I really have with the APICommonBackend solution is that I really want every implementation of an API to have include the db methods and don\u0027t want to have to switch their code to inherit from a different class. I can\u0027t think of a valid reason an OVSDB backend to not support basic OVSDB ops.\n\nSo...yeah, good question. If we don\u0027t like the AttributeError, I think I\u0027m leaning toward the decorator solution over the property or doing a try/except in each method. Opinions?","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":5756,"name":"Terry Wilson","email":"twilson@redhat.com","username":"otherwiseguy"},"change_message_id":"e02e96836d62e696be2f809b7a1acba168842081","unresolved":false,"context_lines":[{"line_number":98,"context_line":"                    self._nested_txn \u003d None"},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"    def db_create(self, table, **col_values):"},{"line_number":101,"context_line":"        return self._backend.db_create(table, **col_values)"},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"    def db_destroy(self, table, record):"},{"line_number":104,"context_line":"        return self._backend.db_destroy(table, record)"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_19758764","line":101,"range":{"start_line":101,"start_character":15,"end_line":101,"end_character":28},"in_reply_to":"df140735_4b11e55c","updated":"2017-06-02 15:42:07.000000000","message":"Decorator it is!","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"535e9efa2c69a1f5059a8e43fe4099f003156430","unresolved":false,"context_lines":[{"line_number":98,"context_line":"                    self._nested_txn \u003d None"},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"    def db_create(self, table, **col_values):"},{"line_number":101,"context_line":"        return self._backend.db_create(table, **col_values)"},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"    def db_destroy(self, table, record):"},{"line_number":104,"context_line":"        return self._backend.db_destroy(table, record)"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_4b11e55c","line":101,"range":{"start_line":101,"start_character":15,"end_line":101,"end_character":28},"in_reply_to":"df140735_68682f1c","updated":"2017-06-02 15:05:06.000000000","message":"I like the decorator better. I think NotImplementedError is better than AttributeError as the later shows _backend which is an internal thing and that can be confusing for developer using this library.","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"15279f9d9d047d52895857b0f2a75b100f188019","unresolved":false,"context_lines":[{"line_number":54,"context_line":"            self.result \u003d self.commit()"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def requires_backend(f):"},{"line_number":58,"context_line":"    def decorated(self, *args, **kwargs):"},{"line_number":59,"context_line":"        try:"},{"line_number":60,"context_line":"            return f(self, *args, **kwargs)"}],"source_content_type":"text/x-python","patch_set":5,"id":"df140735_8257ceca","line":57,"range":{"start_line":57,"start_character":4,"end_line":57,"end_character":20},"updated":"2017-06-03 09:17:11.000000000","message":"Maybe a simple UT where backend is not defined and where attributeError is raised from a method would be helpful.","commit_id":"428fbd06a78c11009932bfcac82059a8844f8d74"}],"ovsdbapp/backend/__init__.py":[{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"578b01fe1271e3679dfabdfce532643ffe642ecf","unresolved":false,"context_lines":[{"line_number":18,"context_line":"@six.add_metaclass(abc.ABCMeta)"},{"line_number":19,"context_line":"class Backend(object):"},{"line_number":20,"context_line":"    def __init__(self, api):"},{"line_number":21,"context_line":"        self.api \u003d api"},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"    @abc.abstractmethod"},{"line_number":24,"context_line":"    def db_create(self, table, **col_values):"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_65be1ab5","line":21,"range":{"start_line":21,"start_character":13,"end_line":21,"end_character":16},"updated":"2017-06-02 13:49:37.000000000","message":"Maybe _api ?","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":5756,"name":"Terry Wilson","email":"twilson@redhat.com","username":"otherwiseguy"},"change_message_id":"e02e96836d62e696be2f809b7a1acba168842081","unresolved":false,"context_lines":[{"line_number":18,"context_line":"@six.add_metaclass(abc.ABCMeta)"},{"line_number":19,"context_line":"class Backend(object):"},{"line_number":20,"context_line":"    def __init__(self, api):"},{"line_number":21,"context_line":"        self.api \u003d api"},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"    @abc.abstractmethod"},{"line_number":24,"context_line":"    def db_create(self, table, **col_values):"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_aeb9af15","line":21,"range":{"start_line":21,"start_character":13,"end_line":21,"end_character":16},"in_reply_to":"df140735_2b48f184","updated":"2017-06-02 15:42:07.000000000","message":"I was considering Command already outside. Since it is passed to the command, the command could actually modify it if it really wanted to (and it really does I suppose since it is creating transactions, etc.) But, Backends themselves are generally going to be private to the API...so meh.","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":5756,"name":"Terry Wilson","email":"twilson@redhat.com","username":"otherwiseguy"},"change_message_id":"5864bc4e14b22d80186b6300904344ac7d516067","unresolved":false,"context_lines":[{"line_number":18,"context_line":"@six.add_metaclass(abc.ABCMeta)"},{"line_number":19,"context_line":"class Backend(object):"},{"line_number":20,"context_line":"    def __init__(self, api):"},{"line_number":21,"context_line":"        self.api \u003d api"},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"    @abc.abstractmethod"},{"line_number":24,"context_line":"    def db_create(self, table, **col_values):"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_c8197b7a","line":21,"range":{"start_line":21,"start_character":13,"end_line":21,"end_character":16},"in_reply_to":"df140735_65be1ab5","updated":"2017-06-02 14:53:57.000000000","message":"I\u0027m not sure what the standard is. I mean, although we only directly reference .api from Backend subclasses, we specifically *pass* that value to outside classes (Command objects). So if it really is something only to be used internally, it seems like that wouldn\u0027t be kosher.","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"},{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"535e9efa2c69a1f5059a8e43fe4099f003156430","unresolved":false,"context_lines":[{"line_number":18,"context_line":"@six.add_metaclass(abc.ABCMeta)"},{"line_number":19,"context_line":"class Backend(object):"},{"line_number":20,"context_line":"    def __init__(self, api):"},{"line_number":21,"context_line":"        self.api \u003d api"},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"    @abc.abstractmethod"},{"line_number":24,"context_line":"    def db_create(self, table, **col_values):"}],"source_content_type":"text/x-python","patch_set":4,"id":"df140735_2b48f184","line":21,"range":{"start_line":21,"start_character":13,"end_line":21,"end_character":16},"in_reply_to":"df140735_c8197b7a","updated":"2017-06-02 15:05:06.000000000","message":"But do we want expose it to the outside? The Command also internal to the point where it\u0027s returned. Though it was a request for opinion.","commit_id":"b9db26ee8acebf0699633e60bcfd8e7989996dc9"}],"ovsdbapp/tests/unit/test_api.py":[{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"a1c68d601d5fbf306a6f17ca95e7283268ea8113","unresolved":false,"context_lines":[{"line_number":35,"context_line":"        return FakeTransaction()"},{"line_number":36,"context_line":""},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"TestingAPI.__abstractmethods__ \u003d set()"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"class TransactionTestCase(base.TestCase):"}],"source_content_type":"text/x-python","patch_set":6,"id":"bf091321_b92aa9e4","line":38,"range":{"start_line":38,"start_character":0,"end_line":38,"end_character":30},"updated":"2017-06-08 09:02:33.000000000","message":"Nice, I wasn\u0027t that smart when I needed this :) : https://review.openstack.org/#/c/416647/5/neutron/tests/unit/agent/ovsdb/test_api.py#37","commit_id":"e2364a7872e248389b6440c3e1e02505f4e4487b"},{"author":{"_account_id":5756,"name":"Terry Wilson","email":"twilson@redhat.com","username":"otherwiseguy"},"change_message_id":"f392c406b1a184e46becf24bcd271cdbd0510858","unresolved":false,"context_lines":[{"line_number":35,"context_line":"        return FakeTransaction()"},{"line_number":36,"context_line":""},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"TestingAPI.__abstractmethods__ \u003d set()"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"class TransactionTestCase(base.TestCase):"}],"source_content_type":"text/x-python","patch_set":6,"id":"bf091321_e0361db5","line":38,"range":{"start_line":38,"start_character":0,"end_line":38,"end_character":30},"in_reply_to":"bf091321_b92aa9e4","updated":"2017-06-08 12:37:04.000000000","message":"Laziness is a virtue!","commit_id":"e2364a7872e248389b6440c3e1e02505f4e4487b"},{"author":{"_account_id":8655,"name":"Jakub Libosvar","email":"libosvar@redhat.com","username":"jlibosva"},"change_message_id":"779124b2d3a8f30d2c984fbc7c5daccfa3d1b5a1","unresolved":false,"context_lines":[{"line_number":35,"context_line":"        return FakeTransaction()"},{"line_number":36,"context_line":""},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"TestingAPI.__abstractmethods__ \u003d set()"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"class TransactionTestCase(base.TestCase):"}],"source_content_type":"text/x-python","patch_set":6,"id":"bf091321_f94701bc","line":38,"range":{"start_line":38,"start_character":0,"end_line":38,"end_character":30},"in_reply_to":"bf091321_b92aa9e4","updated":"2017-06-08 09:03:21.000000000","message":"https://review.openstack.org/#/c/416647/5/neutron/tests/unit/agent/ovsdb/test_api.py@37","commit_id":"e2364a7872e248389b6440c3e1e02505f4e4487b"}]}
