entity.py
branchstable
changeset 3919 f91bd15f427c
parent 3826 0c0c051863cb
child 3955 235a9fda6058
equal deleted inserted replaced
3918:0b7390acca7f 3919:f91bd15f427c
   197                 setattr(cls, rschema.type, SubjectRelation(rschema))
   197                 setattr(cls, rschema.type, SubjectRelation(rschema))
   198             else:
   198             else:
   199                 attr = 'reverse_%s' % rschema.type
   199                 attr = 'reverse_%s' % rschema.type
   200                 setattr(cls, attr, ObjectRelation(rschema))
   200                 setattr(cls, attr, ObjectRelation(rschema))
   201         if mixins:
   201         if mixins:
   202             cls.__bases__ = tuple(mixins + [p for p in cls.__bases__ if not p is object])
   202             # see etype class instantation in cwvreg.ETypeRegistry.etype_class method:
   203             cls.debug('plugged %s mixins on %s', mixins, etype)
   203             # due to class dumping, cls is the generated top level class with actual
       
   204             # user class as (only) parent. Since we want to be able to override mixins
       
   205             # method from this user class, we have to take care to insert mixins after that
       
   206             # class
       
   207             #
       
   208             # note that we don't plug mixins as user class parent since it causes pb
       
   209             # with some cases of entity classes inheritance.
       
   210             mixins.insert(0, cls.__bases__[0])
       
   211             mixins += cls.__bases__[1:]
       
   212             cls.__bases__ = tuple(mixins)
       
   213             cls.info('plugged %s mixins on %s', mixins, cls)
   204 
   214 
   205     @classmethod
   215     @classmethod
   206     def fetch_rql(cls, user, restriction=None, fetchattrs=None, mainvar='X',
   216     def fetch_rql(cls, user, restriction=None, fetchattrs=None, mainvar='X',
   207                   settype=True, ordermethod='fetch_order'):
   217                   settype=True, ordermethod='fetch_order'):
   208         """return a rql to fetch all entities of the class type"""
   218         """return a rql to fetch all entities of the class type"""