# HG changeset patch # User Sylvain Thénault # Date 1259309334 -3600 # Node ID f91bd15f427c856218d0fe66ef9e2da7410ec8a6 # Parent 0b7390acca7f64f06e46c71bc84ff9a1d9acb13d fix nasty pluggable mixins bug, where mixins take precedence other user class diff -r 0b7390acca7f -r f91bd15f427c entity.py --- a/entity.py Wed Nov 25 11:14:04 2009 -0800 +++ b/entity.py Fri Nov 27 09:08:54 2009 +0100 @@ -199,8 +199,18 @@ attr = 'reverse_%s' % rschema.type setattr(cls, attr, ObjectRelation(rschema)) if mixins: - cls.__bases__ = tuple(mixins + [p for p in cls.__bases__ if not p is object]) - cls.debug('plugged %s mixins on %s', mixins, etype) + # see etype class instantation in cwvreg.ETypeRegistry.etype_class method: + # due to class dumping, cls is the generated top level class with actual + # user class as (only) parent. Since we want to be able to override mixins + # method from this user class, we have to take care to insert mixins after that + # class + # + # note that we don't plug mixins as user class parent since it causes pb + # with some cases of entity classes inheritance. + mixins.insert(0, cls.__bases__[0]) + mixins += cls.__bases__[1:] + cls.__bases__ = tuple(mixins) + cls.info('plugged %s mixins on %s', mixins, cls) @classmethod def fetch_rql(cls, user, restriction=None, fetchattrs=None, mainvar='X',