Ticket #6214: optimized.models.base.diff

File optimized.models.base.diff, 1.1 KB (added by Ivan Illarionov, 17 years ago)

small optimization of previous patch

  • base.py

     
    2424    def __new__(cls, name, bases, attrs):
    2525        # If this isn't a subclass of Model, don't do anything special.
    2626        try:
    27             if not filter(lambda b: issubclass(b, Model), bases):
     27            parents = filter(lambda b: issubclass(b, Model), bases)
     28            if not parents:
    2829                return super(ModelBase, cls).__new__(cls, name, bases, attrs)
    2930        except NameError:
    3031            # 'Model' isn't defined yet, meaning we're looking at Django's own
     
    3940            types.ClassType('MultipleObjectsReturned', (MultipleObjectsReturned, ), {}))
    4041
    4142        # Build complete list of parents
    42         for base in bases:
    43             # TODO: Checking for the presence of '_meta' is hackish.
    44             if '_meta' in dir(base):
     43        for base in parents:
     44            if base is not Model:
    4545                new_class._meta.parents.append(base)
    4646                new_class._meta.parents.extend(base._meta.parents)
    4747
Back to Top