Sorry, I had problems to get to my google account, but finally I'm here :).

I wrote to the ticket meanwhile, but you probably not in CC, so I paste it 
here, too:

Having this example:
 
class View(object):
    def __init__(self):
        print "View init"
        #super(View, self).__init__()

class SomeMixin(object):
    def __init__(self):
        print "SomeMixin init"
        super(SomeMixin, self).__init__()

class MyView(View, SomeMixin):
    def __init__(self):
        print "MyVIew init"
        super(MyView, self).__init__()

MyView()
 

With the commented line in the View class, the method SomeMixin.__init__ is 
not called, because mro chain is broken, that's the reason why I filled the 
ticket.
 
Practical use - for exemple in current mixins, there are instance 
attributes which are not defined in __init__, which is bad, code is harder 
to read when new attributes pop up on unusual places, every checker like 
pylint displays warning like:
 
W:127,8:ModelFormMixin.form_valid: Attribute 'object' defined outside __init__
 

So in ModelFormMixin, there should be __init__ which defines 'object' 
attribute (self.object = None), which is IMHO more than good practice.
 
Also having attribute 'object' in __init__, we could avoid ugly 
constructions like now (also in views/generic/edit.py):
 
elif hasattr(self, 'object') and self.object is not None:
 

And that's example in Django itself, I bet there could be lot more in 
various cases of other developers views/mixins, which are hurt by broken 
mro chain.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/fb4b4508-99bf-4156-bbdd-f9ee4a957bbd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to