def _dbids_to_id_string(dbids):
    """Internal function: convert a list of ids to a comma-seperated string"""
    # NOTE: the server strips out non-numeric characters
    # Eg, "-1" is treated as "1".  So do some sanity checking.
    # XXX Should I check for non-digits?
    # Are any of the IDs non-integers?
    if not dbids:
        raise TypeError("dbids list must have at least one term")
    for x in dbids.ids:
        if "," in x:
            raise TypeError("identifiers cannot contain a comma: %r " %
                            (x,))
    id_string = ",".join(dbids.ids)
    assert id_string.count(",") == len(dbids.ids)-1, "double checking"
    return id_string