Tryton - Issues

 

Message32375

Author jcavallo
Recipients ced, nicoe, pokoli, reviewbot
Date 2017-03-09.10:07:01
Content
> On 2017-03-08 15:01, Jean CAVALLO wrote:
> > > I do not see the point. This makes Tryton "Mixin" inheritance
> > > working differently than the usual inheritance.
> > 
> > I am not sure to understand what you mean, could you elaborate ?
> 
> It is bad to have different behaviour.

I meant that I do not see what you mean by "This makes Tryton Mixin inheritance
working differently than the usual inheritance.

> > For instance, if one wants to override the TaxLineMixin class,
> > the mro will be something like :
> > 
> > TaxLineMixinOverride
> > account.invoice.line
> > TaxLineMixin
> 
> I see no problem.

Consider the following :

class Mixin:
    def value(self):
        return 10


class MixinOverride(Mixin):
    def value(self):
        return super(MixinOverride, self).value() + 1


class MyModel(Mixin):
    __name__ = 'my_model'
    def value(self):
        return super(MyModel, self).value() * 2


The difference between the mros is that if MixinOverride is at the end, the
final result will be 21. If it is right after Mixin, it will be 22.

I think the second version is what would be expected.
History
Date User Action Args
2017-03-09 10:07:01jcavallosetmessageid: <1489050421.44.0.271742920229.issue4735@tryton.org>
2017-03-09 10:07:01jcavallosetrecipients: + ced, nicoe, pokoli, reviewbot
2017-03-09 10:07:01jcavallolinkissue4735 messages
2017-03-09 10:07:01jcavallocreate

Showing 10 items. Show all history (warning: this could be VERY long)