When the owner fails to perform his part of the contract and by reason thereof the other party, without his own default, is prevented from completely performing his part, he shall be entitled to reasonable compensation for so much as he shall have performed, in proportion to the price stipulated for the whole, and shall have such a lien as is provided in this article, to secure payment thereof, when such lien is properly perfected and preserved according to the provisions of this article.