Well you can listen to the attributes for connections made, or if you know the keyframe node its attributes.
However this sort of interdiction is not very smart, since it will make it very hard to undo your actions.so you would need to manipulate the undo stack as well. (now thats not entirely trivial.)
There's a bit cleaner way to set this up, by making the cube ans sphere share the transform node, and then just decouple the cube form the transform. Or at least that would probably fit the bill but you didn't explain what it is your after just what you think is what you want to do.*
99% of cases whenever somebody mentions scriptjobs and they dont relate to GUI's updates they are doing something they shouldn't be. Reason being that maya doesn't operate on events in the way most programmers assume and when they see scriptjob they go events gee that's what i want. In reality they dont want to do this, so they get confused. So i only ever advice anybody to use scriptjobs IF and only if they have 3 years of mel/maya Api experience under their belt
*This is not wise strategy. It far better to ask advice on what to do than how to do this. What to do gets better answers for the same cost as how to achieve this. Usually the later leads to another question you can not solve, its far more cost effective to ask the whole process in one go, as it leverages on the know how in multiple dimensions simultaneously. While there may be 20 or so valid approaches to start with the answerer might have crossed out the 19 alternatives out of the list allready in his life giving you the shortest and most elegant route.