Ticket #7621: metaclass.diff

File metaclass.diff, 1.7 KB (added by Christian Tanzer <tanzer@…>, 16 years ago)
  • django/db/models/base.py

     
    3232    "Metaclass for all models"
    3333    def __new__(cls, name, bases, attrs):
    3434        # If this isn't a subclass of Model, don't do anything special.
     35        super_new = super(ModelBase, cls).__new__
    3536        try:
    3637            parents = [b for b in bases if issubclass(b, Model)]
    3738        except NameError:
     
    3940            # Model class, defined below.
    4041            parents = []
    4142        if not parents:
    42             return super(ModelBase, cls).__new__(cls, name, bases, attrs)
     43            return super_new(cls, name, bases, attrs)
    4344
    4445        # Create the class.
    4546        module = attrs.pop('__module__')
    46         new_class = type.__new__(cls, name, bases, {'__module__': module})
     47        new_class = super_new(cls, name, bases, {'__module__': module})
    4748        attr_meta = attrs.pop('Meta', None)
    4849        abstract = getattr(attr_meta, 'abstract', False)
    4950        if not attr_meta:
  • django/newforms/forms.py

     
    5656    """
    5757    def __new__(cls, name, bases, attrs):
    5858        attrs['base_fields'] = get_declared_fields(bases, attrs)
    59         return type.__new__(cls, name, bases, attrs)
     59        return super(DeclarativeFieldsMetaclass,
     60                     cls).__new__(cls, name, bases, attrs)
    6061
    6162class BaseForm(StrAndUnicode):
    6263    # This is the main implementation of all the Form logic. Note that this
Back to Top