Section 127. Any person who has held an appointive office in a city, town or district for at least five consecutive years shall be eligible to apply for tenure in such office pursuant to the provisions of sections one hundred and twenty-six to one hundred and thirty-two, inclusive, with the exception of the following offices:—city or town manager, executive secretary to the selectmen, city or assistant city solicitor, town or assistant town counsel, and legislative counsel. Any person having tenure in a city or town office who is elected to or accepts an appointment to any of the foregoing offices, whether or not to fill a vacancy, shall thereupon lose such tenure. Any person having tenure in an appointive city or town office may not apply for tenure in any other city or town office, nor may any person apply for tenure in more than one city or town office at any one time, except that a person may apply for tenure as city clerk and city treasurer or town clerk and town treasurer, or, if such person has tenure in either of such offices, he may apply for tenure in the other office; provided that both such offices are appointive offices. If any person is unable to so apply for tenure by reason of holding one of the offices specified above or loses his tenure by reason of being elected or appointed to any such office, he may, following the termination of his service in such office, then apply for tenure in an appointive city or town office. Any person granted tenure of office under these provisions shall, notwithstanding any contrary provision of general or special laws, hold office during good behavior until he has attained age sixty-five unless incapacitated by physical or mental disability from performing the duties thereof, but may be removed for cause after a hearing as provided by sections forty-one to forty-five, inclusive, of chapter thirty-one.