Ticket #2363: base.py.2.patch
File base.py.2.patch, 961 bytes (added by , 18 years ago) |
---|
-
base.py
22 22 "Metaclass for all models" 23 23 def __new__(cls, name, bases, attrs): 24 24 # If this isn't a subclass of Model, don't do anything special. 25 if name == 'Model' or not filter(lambda b: issubclass(b, Model), bases): 25 try: 26 if not filter(lambda b: issubclass(b, Model), bases): 27 return super(ModelBase, cls).__new__(cls, name, bases, attrs) 28 except NameError: 29 # Model isn't defined yet, meaning we're looking at django's own Model defined below 26 30 return super(ModelBase, cls).__new__(cls, name, bases, attrs) 27 31 28 32 # Create the class. 29 33 new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')}) 30 34 new_class.add_to_class('_meta', Options(attrs.pop('Meta', None)))