A Kolmogorov-Szegö-Krein type condition for weighted Sobolev spaces