Heat the oil
in a heavy based frying pan over low heat. Cook the onion and sugar,
stirring for 45 minutes, or until the onion is caramelized. Sift the
flour into a bowl. Rub in the butter with your fingertips until the
mixture resembles fine breadcrumbs. Make a well in the center and add
3-4 tablespoons cold water. Mix with a flat-bladed knife, using a
cutting action until the mixture gathers in beads. Gently press together
and lift onto a lightly floured surface. Shape into a ball, wrap in
plastic wrap and chill for 30 minutes. Preheat the oven to 350F, Gas 4.
Lightly grease a 23cm (9") loose based flan tin. Roll out the pastry on
a floured surface, and invert over the tin. Press in with a small ball
of pastry, trim and chill for 10 minutes. Line the pastry with baking
paper and fill with baking beads. Bake the case on a tray for 10
minutes. Remove the beads and paper, and bake for 10 minutes, or until
pale gold and dry. Cool, then spread the onion over the pastry base.
Whisk the cream, eggs, cheese, thyme and some freshly ground black
pepper together, then pour over the onion and bake for 35 minutes, or
until firm.