)]}'
{"glance/image_cache/__init__.py":[{"author":{"_account_id":475,"name":"Rick Harris","email":"rick.harris@rackspace.com","username":"rconradharris"},"change_message_id":"d6d49e77bf94d396b85558bb19b161901501ce90","unresolved":false,"context_lines":[{"line_number":42,"context_line":"        ]"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"    @classmethod"},{"line_number":45,"context_line":"    def new(cls, conf):"},{"line_number":46,"context_line":"        conf.register_opts(cls.opts)"},{"line_number":47,"context_line":"        driver_class \u003d cls.determine_driver_class(conf)"},{"line_number":48,"context_line":"        driver \u003d cls.create_driver(driver_class, conf)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAEn%2F%2F8Sw%3D","line":45,"updated":"2012-02-10 17:04:45.000000000","message":"I\u0027m not seeing why `new` is necessary. Couldn\u0027t we do something like:\n\n\ndef __init__(self, conf, driver\u003dNone):\n    conf.register_opts(self.opts)\n    if not driver:\n        driver_class \u003d self.determine_driver_class(conf)\n        driver \u003d self.create_driver(driver_class, conf)\n\n    self.conf \u003d conf\n    self.driver \u003d driver","commit_id":"b336618d3d83849bff7b14123f05d27f51f1386b"},{"author":{"_account_id":706,"name":"Brian Lamar","email":"brian.lamar@rackspace.com","username":"blamar"},"change_message_id":"79be75798f96ca4e49ea51ec54de6eaee0500239","unresolved":false,"context_lines":[{"line_number":42,"context_line":"        ]"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"    @classmethod"},{"line_number":45,"context_line":"    def new(cls, conf):"},{"line_number":46,"context_line":"        conf.register_opts(cls.opts)"},{"line_number":47,"context_line":"        driver_class \u003d cls.determine_driver_class(conf)"},{"line_number":48,"context_line":"        driver \u003d cls.create_driver(driver_class, conf)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAAEn%2F%2F8SI%3D","line":45,"in_reply_to":"AAAAEn%2F%2F8Sw%3D","updated":"2012-02-10 17:21:04.000000000","message":"This was the original intent, but using DI hasn\u0027t been well-accepted in the past. With both you and Jay asking this question I think we should go this route.\n\nAs an aside, this type of method makes perfect sense when trying to eliminate logic from methods. In your version you\u0027re adding an \u0027if\u0027 statement, and in Mark\u0027s original version he doesn\u0027t add one. In this case it\u0027s just a single \u0027if\u0027 but in the long run adding factory methods such as this one for creating objects in different ways makes a great deal of sense but is not something you find a lot of in Python.\n\nIn the past I\u0027ve made methods like this but I would have called something like:\n\n    @classmethod\n    def from_conf(cls, conf):\n        ...\n\nand then maybe:\n\n    @classmethod\n    def from_other(cls, other):\n        ...\n\ninstead of having to have X number of DI points in the __init__ you\u0027d end up with X ways to create the object with logic for each of those ways encapsulated in the class methods instead of logic in the __init__.","commit_id":"b336618d3d83849bff7b14123f05d27f51f1386b"}]}
