• Xiaowu Zhang's avatar
    portal_type_class: possible to overwrite methods or properties in mixin · c9171e86
    Xiaowu Zhang authored
    Before this change, class hierarchy is like this when using mixin:
    
    class MyClass(BaseClass, Mixin1....)
    which is usually ok when classes don't override each other's
    But if we want to overwrite BaseClass's method by using mixin to do more thing,
    For example:
    
    class BaseClass(object):
      def test(self):
        print 'base test'
    
    class Mixin1(object):
      def test(self):
        super(Mixin,self).test()
        print 'mixin'
    
    I want to display 'mixin base test' when call test, but it doesn't work
    since priority of how methods are resolved is from left
    to right: BaseClass----->Mixin1, it only display 'base test'
    
    So the correct way to use mixin should be in reverse order:
    
    class MyClass(Mixin1, BaseClass)
    c9171e86
portal_type_class.py 20.4 KB