#NEWLINE# def __new__( meta , class_name , bases , class_dict ) : #NEWLINE# #INDENT# '\n        Create subclasses of MPTTModel. This:\n         - adds the MPTT fields to the class\n         - adds a TreeManager to the model\n        ' #NEWLINE# if ( ( class_name == 'NewBase' ) and ( class_dict == { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) : #NEWLINE# #INDENT# return super ( MPTTModelBase , meta ) . __new__ ( meta , class_name , bases , class_dict ) #NEWLINE# #UNINDENT# is_MPTTModel = False #NEWLINE# try : #NEWLINE# #INDENT# MPTTModel #NEWLINE# #UNINDENT# except NameError : #NEWLINE# #INDENT# is_MPTTModel = True #NEWLINE# #UNINDENT# MPTTMeta = class_dict . pop ( 'MPTTMeta' , None ) #NEWLINE# if ( not MPTTMeta ) : #NEWLINE# #INDENT# class MPTTMeta ( ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# initial_options = frozenset ( dir ( MPTTMeta ) ) #NEWLINE# for base in bases : #NEWLINE# #INDENT# if hasattr ( base , '_mptt_meta' ) : #NEWLINE# #INDENT# for ( name , value ) in base . _mptt_meta : #NEWLINE# #INDENT# if ( name == 'tree_manager_attr' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( name not in initial_options ) : #NEWLINE# #INDENT# setattr ( MPTTMeta , name , value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# class_dict [ '_mptt_meta' ] = MPTTOptions ( MPTTMeta ) #NEWLINE# super_new = super ( MPTTModelBase , meta ) . __new__ #NEWLINE# cls = super_new ( meta , class_name , bases , class_dict ) #NEWLINE# cls = meta . register ( cls ) #NEWLINE# cls . _mptt_tracking_base = None #NEWLINE# if is_MPTTModel : #NEWLINE# #INDENT# bases = [ cls ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bases = [ base for base in cls . mro ( ) if issubclass ( base , MPTTModel ) ] #NEWLINE# #UNINDENT# for base in bases : #NEWLINE# #INDENT# if ( ( not ( base . _meta . abstract or base . _meta . proxy ) ) and ( base . _tree_manager . tree_model is base ) ) : #NEWLINE# #INDENT# cls . _mptt_tracking_base = base #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( cls is cls . _mptt_tracking_base ) : #NEWLINE# #INDENT# cls . _threadlocal = threading . local ( ) #NEWLINE# #UNINDENT# return cls