)]}'
{"quantum/quota.py":[{"author":{"_account_id":6139,"name":"Juergen Brendel","email":"jbrendel@cisco.com","username":"jbrendel"},"change_message_id":"b9a318fdc844afab46fc5958fde870d2c8a34cde","unresolved":false,"context_lines":[{"line_number":273,"context_line":"    # if present. Otherwise just use regular getter to retrieve all objects"},{"line_number":274,"context_line":"    # and count in python, allowing older plugins to still be supported"},{"line_number":275,"context_line":"    if hasattr(plugin, count_getter_name):"},{"line_number":276,"context_line":"        try:"},{"line_number":277,"context_line":"            obj_count_getter \u003d getattr(plugin, count_getter_name)"},{"line_number":278,"context_line":"            return obj_count_getter(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":279,"context_line":"        except exceptions.NotImplementedError:"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAMH%2F%2F1eA%3D","line":276,"updated":"2012-11-20 19:54:51.000000000","message":"Yes, this looks like it will work. Consider that the very first versions of this didn\u0027t have hasattr() at all. Instead, it relied entirely on exceptions. But stepping into a try/except block has a small performance impact, which we tried to avoid by using hasattr() instead. Now, we have both hasattr() AND the exception.\n\nI wonder if we can now just remove the hasattr() check altogether and completely rely on the exception? Since the count method is part of the base plugin now, it seems the hasattr() will always be successful, so in most cases it really shouldn\u0027t return False anymore.\n\nThe exception could catch both types of exceptions:\n\nexcept (AttributeError, exceptions.NotImplementedError) as e:\n\nOr similar.","commit_id":"1c417344d6d83764eb03aa447cb309da4331a2bf"},{"author":{"_account_id":447,"name":"dan wendlandt","email":"dan@nicira.com","username":"danwent"},"unresolved":false,"context_lines":[{"line_number":273,"context_line":"    # if present. Otherwise just use regular getter to retrieve all objects"},{"line_number":274,"context_line":"    # and count in python, allowing older plugins to still be supported"},{"line_number":275,"context_line":"    if hasattr(plugin, count_getter_name):"},{"line_number":276,"context_line":"        try:"},{"line_number":277,"context_line":"            obj_count_getter \u003d getattr(plugin, count_getter_name)"},{"line_number":278,"context_line":"            return obj_count_getter(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":279,"context_line":"        except exceptions.NotImplementedError:"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAMH%2F%2F1aM%3D","line":276,"in_reply_to":"AAAAMH%2F%2F1eA%3D","updated":"2012-11-20 20:30:30.000000000","message":"Yeah, probably cleaner to handle them both as exceptions..","commit_id":"1c417344d6d83764eb03aa447cb309da4331a2bf"}]}
