The problem here is that the object does not have the property matrix_world.inverted().
When you try to use such thing, you are in fact trying to compute something inside a variable. You are trying to invert the matrix.
Unfortunately the only place where you can perform computations in drivers is in “Expr:”.
At the moment the only thing that I managed to come up with is to write the full path to “Expr:”, so it would look something like this:
Unfortunately this will throw gazillion warnings at you, you’ll be advised to use variables instead and so on, so I’m not sure what problems such approach may cause.
The other issue is that you have to write eeeeeeeeverything with full paths in this one little line “Expr:”.
Will try to think about it a bit more, maybe I’ll come up with something
I made some tests with custom python nodes and results are really great! Any property of an object can be passed to a socket with a python function. Inverted matrix is then really easy to setup and use. It works on the compositor and Cycles.