def __new__(cls, name, bases, attrs): super_new = super(DocumentMeta, cls).__new__ parents = [b for b in bases if isinstance(b, DocumentMeta)] if not parents: return super_new(cls, name, bases, attrs) new_class = super_new(cls, name, bases, attrs) attr_meta = attrs.pop('Meta', None) if not attr_meta: meta = getattr(new_class, 'Meta', None) else: if getattr(attr_meta, 'abstract', False): return new_class meta = attr_meta if getattr(meta, 'app_label', None) is None: document_module = sys.modules[new_class.__module__] app_label = document_module.__name__.split('.')[-2] else: app_label = getattr(meta, 'app_label') new_class.add_to_class('_meta', Options(meta, app_label=app_label)) register_schema(app_label, new_class) return get_schema(app_label, name)
def __new__(cls, name, bases, attrs): super_new = super(DocumentMeta, cls).__new__ parents = [b for b in bases if isinstance(b, DocumentMeta)] if not parents: return super_new(cls, name, bases, attrs) new_class = super_new(cls, name, bases, attrs) document_module = sys.modules[new_class.__module__] app_label = document_module.__name__.split('.')[-2] register_schema(app_label, new_class) return get_schema(app_label, name)
def __new__(cls, name, bases, attrs): super_new = super(DocumentMeta, cls).__new__ parents = [b for b in bases if isinstance(b, DocumentMeta)] if not parents: return super_new(cls, name, bases, attrs) new_class = super_new(cls, name, bases, attrs) attr_meta = attrs.pop('Meta', None) if not attr_meta: meta = getattr(new_class, 'Meta', None) else: meta = attr_meta if getattr(meta, 'app_label', None) is None: document_module = sys.modules[new_class.__module__] app_label = document_module.__name__.split('.')[-2] else: app_label = getattr(meta, 'app_label') new_class.add_to_class('_meta', Options(meta, app_label=app_label)) register_schema(app_label, new_class) return get_schema(app_label, name)