(domain, contact_id)
return (False, session)
Retrieves the current open SQLXFormsSession for the given contact.
    If multiple sessions are open, it closes all of them and returns
    None for the session.

    The return value is a tuple of (multiple, session), where multiple
    is True if there were multiple sessions, and session is the session if
    there was a single open session available.
Retrieves the current open SQLXFormsSession for the given contact.
    If multiple sessions are open, it closes all of them and returns
    None for the session.
Retrieves the current open SQLXFormsSession for the given contact . If multiple sessions are open it closes all of them and returns None for the session .
def get_single_open_session_or_close_multiple(domain, contact_id):
    """
    Retrieves the current open SQLXFormsSession for the given contact.
    If multiple sessions are open, it closes all of them and returns
    None for the session.

    The return value is a tuple of (multiple, session), where multiple
    is True if there were multiple sessions, and session is the session if
    there was a single open session available.
    """
    sessions = SQLXFormsSession.get_all_open_sms_sessions(domain, contact_id)
    count = sessions.count()
    if count > 1:
        for session in sessions:
            session.mark_completed(False)
            session.save()
        return (True, None)

    session = sessions[0] if count == 1 else None
    return (False, session)
def get_single_open_session_or_close_multiple ( domain , contact_id ) : sessions = SQLXFormsSession . get_all_open_sms_sessions ( domain , contact_id ) count = sessions . count ( ) if count > 1 : for session in sessions : session . mark_completed ( False ) session . save ( ) return ( True , None ) session = sessions [ 0 ] if count == 1 else None return ( False , session )