#15062: r14389 breaks getattr on Manager subclasses
---------------------------------------------------+------------------------
          Reporter:  clelland                      |         Owner:  nobody
            Status:  reopened                      |     Milestone:  1.3   
         Component:  Database layer (models, ORM)  |       Version:  SVN   
        Resolution:                                |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by clelland):

 Interestingly, I didn't even realise that I wasn't using !QuerySetManager
 straight from the snippet (the comment referencing djangosnippets is in my
 code, but I've been using it for so long that I forgot where my current
 version *actually* came from).

 The comments at the bottom of [http://djangosnippets.org/snippets/734/]
 show the full version I am using (specifically, the addition in
 [http://djangosnippets.org/snippets/734/#c903]). It is described in more
 detail at [http://seanmonstar.com/post/708862164/extending-django-models-
 managers-and-querysets]. The models.py file I attached also includes it.

 {{{
 class QuerySetManager(models.Manager):
         def get_query_set(self):
                 return self.model.QuerySet(self.model)
         def __getattr__(self, attr, *args):
                 return getattr(self.get_query_set(), attr, *args)
 }}}

 The important (and breaking) bit is the `__getattr__` override -- that
 used to delegate (through the !RelatedManager parent) to the queryset
 defined in the model; now, it looks to me like the !RelatedManager is
 calling get_query_set again, which somehow gets back to the
 !QuerySetManager code, and starts the cycle anew, and so on until the
 stack limit is exceeded.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15062#comment:3>
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to