#NEWLINE# def _set_iterable( self , state , dict_ , iterable , adapter = None ) : #NEWLINE# #INDENT# 'Set a collection value from an iterable of state-bearers.\n\n        ``adapter`` is an optional callable invoked with a CollectionAdapter\n        and the iterable.  Should return an iterable of state-bearing\n        instances suitable for appending via a CollectionAdapter.  Can be used\n        for, e.g., adapting an incoming dictionary into an iterator of values\n        rather than keys.\n\n        ' #NEWLINE# ( new_collection , user_data ) = self . _initialize_collection ( state ) #NEWLINE# if adapter : #NEWLINE# #INDENT# new_values = list ( adapter ( new_collection , iterable ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_values = list ( iterable ) #NEWLINE# #UNINDENT# old = self . get ( state , dict_ , passive = PASSIVE_ONLY_PERSISTENT ) #NEWLINE# if ( new_values is PASSIVE_NO_RESULT ) : #NEWLINE# #INDENT# old = self . initialize ( state , dict_ ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( old is iterable ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# state . _modified_event ( dict_ , self , old , True ) #NEWLINE# old_collection = getattr ( old , '_sa_adapter' ) #NEWLINE# dict_ [ self . key ] = user_data #NEWLINE# collections . bulk_replace ( new_values , old_collection , new_collection ) #NEWLINE# old_collection . unlink ( old )