Raising NotImplementedError makes it impossible to use super() properly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Fix Released
|
Medium
|
Radomir Dopieralski |
Bug Description
There is an antipattern in Python, where to define a "virtual" method people would raise a NotImplementedError exception in the body of the method. This makes it impossible to use super() properly with that method and, because of that, to use multiple inheritance, such as mixins.
Horizon has several places where this is used, including some methods, such as get_context_data, that are very likely to be touched by various mixins. Those methods should return some default, empty value, instead of raising an exception.
A typical implementation of get_context_data() in Django should look something like this:
def get_context_
context = super(OverviewTab, self).get_
})
return context
This will break horribly if the superclass' get_context_data raises NotImplementedE
Changed in horizon: | |
assignee: | nobody → Radomir Dopieralski (thesheep) |
description: | updated |
Changed in horizon: | |
milestone: | none → juno-rc1 |
Changed in horizon: | |
importance: | Undecided → Medium |
Changed in horizon: | |
status: | Fix Committed → Fix Released |
Changed in horizon: | |
milestone: | juno-rc1 → 2014.2 |
Fix proposed to branch: master /review. openstack. org/72629
Review: https:/