Replace cached method calls with @memoized_method
Bug #1248230 reported by
Radomir Dopieralski
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Fix Released
|
Medium
|
Radomir Dopieralski |
Bug Description
There is a certain pattern repeated all over openstack_dashboard for caching results of method calls. It looks something like this:
def get_data(self):
if not hasattr(self, "_data"):
# Calculate data here.
return self._data
This repeating pattern is an example of copy-and-paste programming and can be instead easily abstracted away into a decorator. This way all the logic is in one place and all the code benefits from bugfixes and performance improvement of that code.
Changed in horizon: | |
assignee: | nobody → Radomir Dopieralski (thesheep) |
Changed in horizon: | |
status: | New → In Progress |
Changed in horizon: | |
milestone: | none → icehouse-2 |
importance: | Undecided → Medium |
Changed in horizon: | |
status: | Fix Committed → Fix Released |
Changed in horizon: | |
milestone: | icehouse-2 → 2014.1 |
To post a comment you must log in.
Yeah, this one is ugly. Thanks for picking this up.