  We consider a generalization of the classical pinning problem for
integer-valued random walks conditioned to stay non-negative. More
specifically, we take pinning potentials of the form $\sum_{j\geq 0}\epsilon_j
N_j$, where $N_j$ is the number of visits to the state $j$ and $\{\epsilon_j\}$
is a non-negative sequence. Partly motivated by similar problems for
low-temperature contour models in statistical physics, we aim at finding a
sharp characterization of the threshold of the wetting transition, especially
in the regime where the variance $\sigma^2$ of the single step of the random
walk is small. Our main result says that, for natural choices of the pinning
sequence $\{\epsilon_j\}$, localization (respectively delocalization) occurs if
$\sigma^{-2}\sum_{ j\geq0}(j+1)\epsilon_j\geq\delta^{-1}$ (respectively $\le
\delta$), for some universal $\delta <1$. Our finding is reminiscent of the
classical Bargmann-Jost-Pais criteria for the absence of bound states for the
radial Schr\"odinger equation. The core of the proof is a recursive argument to
bound the free energy of the model. Our approach is rather robust, which allows
us to obtain similar results in the case where the random walk trajectory is
replaced by a self-avoiding path $\gamma$ in $\mathbb Z^2$ with weight
$\exp(-\beta |\gamma|)$, $|\gamma|$ being the length of the path and $\beta>0$
a large enough parameter. This generalization is directly relevant for
applications to the above mentioned contour models.
