Skip to content

Commit

Permalink
Fix all_of_type when used before the ct cache is fully populated
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Mar 23, 2011
1 parent a42a031 commit ea923b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion feincms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ def _popuplate_content_type_caches(self, types):
for pk, ct_idx in counts:
counts_by_type.setdefault(self.item._feincms_content_types[ct_idx], []).append((region, pk))

for type in types:
# Resolve abstract to concrete content types
types = tuple(types)

for type in (type for type in self.item._feincms_content_types if issubclass(type, types)):
counts = counts_by_type.get(type)
if type not in self._cache['cts']:
if counts:
Expand Down
5 changes: 5 additions & 0 deletions feincms/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ def test_09_pagecontent(self):

page2 = Page.objects.get(pk=2)
page2.symlinked_page = page

# Test that all_of_type works correctly even before accessing
# other content methods
self.assertEqual(len(page2.content.all_of_type(RawContent)), 1)

self.assertEqual(page2.content.main[0].__class__.__name__, 'RawContent')
self.assertEqual(unicode(page2.content.main[0]),
'main on Test page, ordering 0')
Expand Down

0 comments on commit ea923b4

Please sign in to comment.