git.ithinksw.org
/
philo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
38c41a2
)
Eliminated unnecessary ContentType queries from AttributeMapper._fill_cache.
author
Stephen Burrows
<stephen.r.burrows@gmail.com>
Wed, 22 Jun 2011 13:54:41 +0000
(09:54 -0400)
committer
Stephen Burrows
<stephen.r.burrows@gmail.com>
Wed, 22 Jun 2011 13:55:01 +0000
(09:55 -0400)
philo/utils/entities.py
patch
|
blob
|
history
diff --git
a/philo/utils/entities.py
b/philo/utils/entities.py
index
1ddff05
..
754a5dc
100644
(file)
--- a/
philo/utils/entities.py
+++ b/
philo/utils/entities.py
@@
-83,15
+83,15
@@
class AttributeMapper(object, DictMixin):
value_lookups = {}
for a in attributes:
value_lookups = {}
for a in attributes:
- value_lookups.setdefault(a.value_content_type, []).append(a.value_object_id)
+ value_lookups.setdefault(a.value_content_type
_id
, []).append(a.value_object_id)
self._attributes_cache[a.key] = a
values_bulk = {}
self._attributes_cache[a.key] = a
values_bulk = {}
- for ct, pks in value_lookups.items():
- values_bulk[ct
] = ct
.model_class().objects.in_bulk(pks)
+ for ct
_pk
, pks in value_lookups.items():
+ values_bulk[ct
_pk] = ContentType.objects.get_for_id(ct_pk)
.model_class().objects.in_bulk(pks)
- self._cache.update(dict([(a.key, getattr(values_bulk[a.value_content_type].get(a.value_object_id), 'value', None)) for a in attributes]))
+ self._cache.update(dict([(a.key, getattr(values_bulk[a.value_content_type
_id
].get(a.value_object_id), 'value', None)) for a in attributes]))
self._cache_filled = True
def clear_cache(self):
self._cache_filled = True
def clear_cache(self):