#NEWLINE# def __new__( mcs , name , bases , dct ) : #NEWLINE# #INDENT# super_new = super ( ModelBase , mcs ) . __new__ #NEWLINE# parents = [ b for b in bases if isinstance ( b , ModelBase ) ] #NEWLINE# if ( not parents ) : #NEWLINE# #INDENT# return super_new ( mcs , name , bases , dct ) #NEWLINE# #UNINDENT# dct [ '_table' ] = tableize ( name ) #NEWLINE# rel_attrs = { rel : dct . setdefault ( rel , ( ) ) for rel in REL_TYPES } #NEWLINE# dct [ '_field_handler_cls' ] = FieldHandlerBase ( ( '%sFieldHandler' % name ) , ( FieldHandler , ) , dict ( rel_attrs , model = name ) ) #NEWLINE# object_handler_cls = dct . setdefault ( 'object_handler' , ObjectHandler ) #NEWLINE# dct [ '_callbacks' ] = { callback : [ ] for callback in CALLBACKS } #NEWLINE# for callback in CALLBACKS : #NEWLINE# #INDENT# if ( callback in dct ) : #NEWLINE# #INDENT# dct [ '_callbacks' ] [ callback ] . append ( callback ) #NEWLINE# #UNINDENT# dct [ '_callbacks' ] [ callback ] . extend ( [ key for ( key , value ) in dct . items ( ) if hasattr ( value , callback ) ] ) #NEWLINE# #UNINDENT# new_class = super_new ( mcs , name , bases , dct ) #NEWLINE# model_registry . register ( name , new_class ) #NEWLINE# setattr ( new_class , 'objects' , object_handler_cls ( new_class ) ) #NEWLINE# return new_class