#NEWLINE# def __new__( cls , name , bases , dct ) : #NEWLINE# #INDENT# new_cls = super ( MetaClass , cls ) . __new__ ( cls , name , bases , dct ) #NEWLINE# fields = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# parents = [ b for b in bases if issubclass ( b , DocumentModel ) ] #NEWLINE# parents . reverse ( ) #NEWLINE# for p in parents : #NEWLINE# #INDENT# parent_fields = getattr ( getattr ( p , '_meta' , None ) , 'fields' , None ) #NEWLINE# if parent_fields : #NEWLINE# #INDENT# fields . update ( parent_fields ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except NameError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# for ( name , field ) in dct . items ( ) : #NEWLINE# #INDENT# if isinstance ( field , Field ) : #NEWLINE# #INDENT# field . add_to_class ( new_cls , name ) #NEWLINE# fields [ name ] = field #NEWLINE# delattr ( new_cls , name ) #NEWLINE# #UNINDENT# #UNINDENT# new_cls . _meta = Options ( fields ) #NEWLINE# return new_cls