A Mexican would use indistinctly "estaba" (underlining when he used to be a student) and "estu
vo" (underlining he's not a student there anymore) in this kind of sentence, because we insert a preposition "de" to evoke the time
from when he had the book.
"Y
(él
) sacó un libro
(de su escuela
) de cuando estaba/estuvo en
(la) primaria".
If you tell a Mexican "...un libro cuando estuvo/estaba...", you'd have to make the distinction Luna has marked, so there is no confusion.
Oh, and we'd probably rather say "un libro de texto" if you're talking about a schoolbook.