#12876: maximum recursion error when caching querysets on models
---------------------------------------------------+------------------------
          Reporter:  zbyte64                       |         Owner:  elachuni
            Status:  new                           |     Milestone:  1.2     
         Component:  Database layer (models, ORM)  |       Version:  1.2-beta
        Resolution:                                |      Keywords:          
             Stage:  Accepted                      |     Has_patch:  0       
        Needs_docs:  0                             |   Needs_tests:  0       
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by elachuni):

  * owner:  nobody => elachuni

Comment:

 {{{django.db.models.sql.Query}}} defines a custom {{{__deepcopy__}}} that
 calls {{{self.clone()}}}, disregarding the provided memo dict.

 So, if the query contains a reference to a model instance that in turn
 contains a reference to a reference (as in this case), deepcopy will end
 up in an endless loop.

 The model itself could work around this problem by providing its own
 {{{__deepcopy__}}} implementation, that just didn't include the query.
 For the example in the bugreport:

 {{{
 #!python
 class TestModel(models.Model):
     def __deepcopy__(self, memo):
         return TestModel(id=self.id)
     ....
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12876#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 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.

Reply via email to