Ticket #7621: metaclass.diff
File metaclass.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/db/models/base.py
32 32 "Metaclass for all models" 33 33 def __new__(cls, name, bases, attrs): 34 34 # If this isn't a subclass of Model, don't do anything special. 35 super_new = super(ModelBase, cls).__new__ 35 36 try: 36 37 parents = [b for b in bases if issubclass(b, Model)] 37 38 except NameError: … … 39 40 # Model class, defined below. 40 41 parents = [] 41 42 if not parents: 42 return super (ModelBase, cls).__new__(cls, name, bases, attrs)43 return super_new(cls, name, bases, attrs) 43 44 44 45 # Create the class. 45 46 module = attrs.pop('__module__') 46 new_class = type.__new__(cls, name, bases, {'__module__': module})47 new_class = super_new(cls, name, bases, {'__module__': module}) 47 48 attr_meta = attrs.pop('Meta', None) 48 49 abstract = getattr(attr_meta, 'abstract', False) 49 50 if not attr_meta: -
django/newforms/forms.py
56 56 """ 57 57 def __new__(cls, name, bases, attrs): 58 58 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) 60 61 61 62 class BaseForm(StrAndUnicode): 62 63 # This is the main implementation of all the Form logic. Note that this