#NEWLINE# def lookup_connections( backend , identities ) : #NEWLINE# #INDENT# '\n    Find connections associated with backend and identities. A new connection\n    object will be created for every backend/identity pair not found.\n\n    :param backend: backend name (as a string) or\n        :py:class:`~rapidsms.backends.base.BackendBase` object\n    :param identities: list of identities to find associated with the backend\n    :returns: List of :py:class:`~rapidsms.models.Connection` objects\n    ' #NEWLINE# if isinstance ( backend , string_types ) : #NEWLINE# #INDENT# ( backend , _ ) = Backend . objects . get_or_create ( name = backend ) #NEWLINE# #UNINDENT# connections = [ ] #NEWLINE# for identity in identities : #NEWLINE# #INDENT# ( connection , _ ) = backend . connection_set . get_or_create ( identity = identity ) #NEWLINE# connections . append ( connection ) #NEWLINE# #UNINDENT# return connections