Possible to script the DOF of a camera to keep track of an object?

In the compositing forum I asked if it was possible to parent the focus of the camera to an object, so you do not have to manually adjust the focus each keyframe.
The only thing that can be done is linking the rotatation/location of the camera, but not the focus point.
Would it be possible to create a script which automatically adds keyframes for the focus keeping track of an object ? Like you run the script once and it adds the correct keys with the correct distance.

you could manually add in keys or script them
or just keep it as a scriptlink.

Thanks ideasman42! This will make the proces of focussing a lot easier!
It’s a shame nobody replied to the thread you wrote with the script.
Thanks man!