Polynomial Constraint Satisfaction: A Framework for Counting and Sampling CSPs and Other Problems