Ticket #2363: base.py.2.patch

File base.py.2.patch, 961 bytes (added by phil.h.smith@…, 18 years ago)

now with less name checks

  • base.py

     
    2222    "Metaclass for all models"
    2323    def __new__(cls, name, bases, attrs):
    2424        # 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
    2630            return super(ModelBase, cls).__new__(cls, name, bases, attrs)
    27 
     31       
    2832        # Create the class.
    2933        new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')})
    3034        new_class.add_to_class('_meta', Options(attrs.pop('Meta', None)))
Back to Top