#NEWLINE# def __new__( cls , name , bases , attrs ) : #NEWLINE# #INDENT# self = super ( ManagedResourceBase , cls ) . __new__ ( cls , name , bases , attrs ) #NEWLINE# if ( not cls . _is_resource ( name , bases ) ) : #NEWLINE# #INDENT# return self #NEWLINE# #UNINDENT# self . attributes = attributes = collections . OrderedDict ( ) #NEWLINE# for base in bases : #NEWLINE# #INDENT# if getattr ( base , 'attributes' , None ) : #NEWLINE# #INDENT# attributes . update ( base . attributes ) #NEWLINE# #UNINDENT# #UNINDENT# for ( index , attribute ) in six . iteritems ( attrs ) : #NEWLINE# #INDENT# if isinstance ( attribute , Attribute ) : #NEWLINE# #INDENT# attributes [ index ] = attr #NEWLINE# #UNINDENT# #UNINDENT# for attr in attributes : #NEWLINE# #INDENT# attributes [ attr ] = attributes [ attr ] . clone ( ) #NEWLINE# if ( not attributes [ attr ] . name ) : #NEWLINE# #INDENT# attributes [ attr ] . name = attr #NEWLINE# #UNINDENT# #UNINDENT# if ( self . meta . slug not in attributes ) : #NEWLINE# #INDENT# if ( not self . meta . abstract ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( 'slug must reference an existing attribute' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . meta . slug = attributes [ self . meta . slug ] #NEWLINE# #UNINDENT# self . preparers = preparers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for key in attributes : #NEWLINE# #INDENT# prepare = getattr ( self , 'prepare_{}' . format ( key ) , None ) #NEWLINE# if ( not prepare ) : #NEWLINE# #INDENT# prepare = ( lambda self , obj , value : value ) #NEWLINE# #UNINDENT# preparers [ key ] = prepare #NEWLINE# #UNINDENT# self . cleaners = cleaners = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for key in attributes : #NEWLINE# #INDENT# clean = getattr ( self , 'clean_{}' . format ( key ) , None ) #NEWLINE# if ( not clean ) : #NEWLINE# #INDENT# clean = ( lambda self , value : value ) #NEWLINE# #UNINDENT# cleaners [ key ] = clean #NEWLINE# #UNINDENT# self . relationships = relationships = collections . OrderedDict ( ) #NEWLINE# for base in bases : #NEWLINE# #INDENT# if getattr ( base , 'relationships' , None ) : #NEWLINE# #INDENT# relationships . update ( base . relationships ) #NEWLINE# #UNINDENT# #UNINDENT# for ( name , attr ) in six . iteritems ( attrs ) : #NEWLINE# #INDENT# if isinstance ( attr , Relationship ) : #NEWLINE# #INDENT# relationships [ name ] = attr #NEWLINE# #UNINDENT# #UNINDENT# for attr in relationships : #NEWLINE# #INDENT# relationships [ attr ] = copy . copy ( relationships [ attr ] ) #NEWLINE# #UNINDENT# return self