Changes between Version 18 and Version 19 of ModelInheritance


Ignore:
Timestamp:
Feb 27, 2006, 5:29:38 PM (19 years ago)
Author:
cell@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ModelInheritance

    v18 v19  
    171171
    172172Thus, there is simply no 'name' field for it to inherit.  So, we need to have ModelBase walk through the parent classes and call contribute_to_class on each of the fields found in _meta.fields.  As we walk the inheritance tree, we look for a '_meta' attribute to determine if our current node is a Model.  Otherwise, it is either a mixin class or the Model class iteself.
     173
     174We can keep track of the parent hierarchy by creating _meta.parents, and having each ancestor of Model add to it in a recursive fasion, by adding the following to  ModelBase.__new__():
     175
     176{{{
     177        new_class._meta.parents = bases
     178        for base in bases:
     179            if '_meta' in dir(base):
     180                new_class._meta.parents.extend(base._meta.parents)
     181
     182}}}
Back to Top