#13460: django.db.models.Model breaks multiple inheritance
----------------------------+-----------------------------------------------
 Reporter:  Art_S           |       Owner:  nobody    
   Status:  new             |   Milestone:            
Component:  Core framework  |     Version:  1.1       
 Keywords:  inheritance     |       Stage:  Unreviewed
Has_patch:  0               |  
----------------------------+-----------------------------------------------
 django.db.models.Model breaks multiple inheritance by not calling

 super(...).__init__(...)

 Here's example code:


 {{{
 from django.db import models

 class A(models.Model):
     def __init__(self, *args, **kwargs):
         super(A, self).__init__(*args, **kwargs)
         print 'A'

     m = models.CharField()

 class B(object):
     def __init__(self, *args, **kwargs):
         super(B, self).__init__(*args, **kwargs)
         print 'B'

 class C(object):
     def __init__(self, *args, **kwargs):
         super(C, self).__init__(*args, **kwargs)
         print 'C'

 class D(A, B, C):
     def __init__(self, *args, **kwargs):
         super(D, self).__init__(*args, **kwargs)
         print 'D'

 D()
 }}}

 Resulting in:

 {{{
 A
 D
 }}}


 However as soon as I remove models.Model from parent for A and replace it
 with 'object', all the constructors are getting called and the output is:


 {{{
 C
 B
 A
 D
 }}}


 Apparently this happens because MRO is nto beign composed properly when
 you ommit calls to parent's __init__, even if it's the object.
 See http://fuhm.net/super-harmful/ for more details.

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