#12876: maximum recursion error when caching querysets on models ---------------------------+------------------------------------------------ Reporter: zbyte64 | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.2-beta Keywords: | Stage: Unreviewed Has_patch: 0 | ---------------------------+------------------------------------------------ The following test case causes a runtime exception against django 1.2 beta 1:
{{{ from django.test import TestCase from django.db import models class TestModel(models.Model): def cachedmethod(self): if not hasattr(self, '_cachedmethod'): self._cachedmethod = RelatedModel.objects.all().filter(test_model=self) return self._cachedmethod class RelatedModel(models.Model): test_model = models.ForeignKey(TestModel) category = models.CharField(max_length=50) class dummy(object): def __init__(self, parent): self.parent = parent def cachedmethod(self): if not hasattr(self, '_cachedmethod'): self._cachedmethod = RelatedModel.objects.all().filter(test_model=self.parent) return self._cachedmethod class BreakMeTest(TestCase): def test_caching(self): parent = TestModel() parent.save() related = RelatedModel(category='foo', test_model=parent) related.save() adummy = dummy(parent) adummy.cachedmethod() adummy.cachedmethod().filter(category='foo') #this doesn't break it parent.cachedmethod() parent.cachedmethod().filter(category='foo') #this breaks it }}} -- Ticket URL: <http://code.djangoproject.com/ticket/12876> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.