Abelian solutions of the KP equation