(contact_id, phone_number)
return SMSChannel(
        backend_id=backend_id,
        phone_number=phone_number,
    )
For a given contact_id, phone_number pair, look up the gateway to be used and return the result as a Channel

    If a PhoneNumber object does not exist for the pair,
    or attempting to determine the gateway backend results in a BadSMSConfigException
    a channel will be returned with backend_id=None
For a given contact_id, phone_number pair, look up the gateway to be used and return the result as a Channel
For a given contact_id phone_number pair look up the gateway to be used and return the result as a Channel
def get_channel_for_contact(contact_id, phone_number):
    """
    For a given contact_id, phone_number pair, look up the gateway to be used and return the result as a Channel

    If a PhoneNumber object does not exist for the pair,
    or attempting to determine the gateway backend results in a BadSMSConfigException
    a channel will be returned with backend_id=None
    """
    backend_id = None
    phone_number_record = PhoneNumber.get_phone_number_for_owner(contact_id, phone_number)
    if phone_number_record:
        try:
            backend = phone_number_record.backend
        except BadSMSConfigException:
            backend = None
        if backend:
            backend_id = backend.couch_id

    return SMSChannel(
        backend_id=backend_id,
        phone_number=phone_number,
    )
def get_channel_for_contact ( contact_id , phone_number ) : backend_id = None phone_number_record = PhoneNumber . get_phone_number_for_owner ( contact_id , phone_number ) if phone_number_record : try : backend = phone_number_record . backend except BadSMSConfigException : backend = None if backend : backend_id = backend . couch_id return SMSChannel ( backend_id = backend_id , phone_number = phone_number , )