Heat the oil in a heavy saucepan and add the whole spices (spilt open the black cardamom and use only the seeds). As soon as the spices start to darken and crackle (this can take anything from a few seconds to a minute, depending in the temperature of the oil), add the onions.
Cook on a high heat, stirring from time to time until the onions start to soften. Lower the heat and cook for 10-12 minutes until they have completely softened. Add the ginger, garlic and chillies and stir for another minute or so.
Add the turmeric and tomato purée, mix well and take off the heat. Put the mixture in an upright blender with just enough cold water to cover it and blend to a fine purée.