def _add_to_index(index, obj):
    """Adds the given object ``obj`` to the given ``index``"""
    id_set = index.value_map.setdefault(indexed_value(index, obj), set())
    if index.unique:
        if len(id_set) > 0:
            raise UniqueConstraintError()
    id_set.add(obj.id)
def _add_to_index ( index , obj ) : id_set = index . value_map . setdefault ( indexed_value ( index , obj ) , set ( ) ) if index . unique : if len ( id_set ) > 0 : raise UniqueConstraintError ( ) id_set . add ( obj . id )
Adds the given object ``obj`` to the given ``index``