Hence relays and diodes
With the doors shut a relay diverts the puddle light supply to the door handle (done in the door). Inside the car, with the door shut, an unlock signal which turns on the interior light also turns on all the puddle lights, but with the doors shut that lights up the handles.