def _set_policy(entity, constraints):
    """
    applies contstraints to entity

    entity is a Bag or a Recipe, constraints a dictionary
    """
    for constraint, value in constraints.items():
        setattr(entity.policy, constraint, value)
