Place flour in a food processor and add butter. Using the pulse button, process in short bursts, until mixture resembles breadcrumbs. Add 3 tbsp water and process in bursts until dough begins to clump together. Pinch a piece to feel if it is moist enough, and add a little more water if it is too crumbly.
Turn out dough onto a work surface, and gather into a ball. Roll out on a sheet of non-stick baking paper to fit a 24cm (base measurement) loose-bottom flan tin. Line tin with pastry, and trim edges (reserve the paper). Refrigerate for 20 minutes.
Preheat oven to 180°C or 160°C fan. Line pastry with paper, and fill with dried rice or pastry weights. Bake for 15 minutes, then remove paper and beans and cook a further 15 minutes, until dry and lightly golden. Cool completely.
Meanwhile, heat oil in a large frying pan and add onions. Cook over medium-low heat for about 35 minutes, until a deep golden colour. Season well with salt and pepper and transfer to a bowl to cool.
Spread cooled onions over pastry base. Sprinkle cheese over, then thyme leaves. Lightly whisk eggs and cream together, and pour over the filling. Stand on a tray and bake for 30-35 minutes, until set and golden. Serve warm, or at room temperature.