When the S.F. judge shot down Trump's sanctuary cities punitive action, what exactly happened? And is there no recourse?

Look,  the government is working off Obama's last "budget."  That fiscal year ends with the last day of this coming September.

Understand that Trump's new budget,  if it makes "compliance" as to ending "sanctuary" status  a requirement for receiving federal funds,  beginning October 1,2017,  that will work.  Right now,  under contract law,  the states have a contract for receiving federal funds with no penalties against sanctuary status.   Why Trump is not waiting for the new budget proposal is beyond me.  At any rate,  eventually,  he will end this lawlessness.    

Update:  Besides the strategy that is the new budget,  October 1, there are grants,  money given to entities and state governments,  money given apart from any contractual ties.  These grants can be taken away at any money and for any reason.  In other words,  pressure can be put on regional governments to comply and the smaller cities with their limited funds,  will not be able to resist the law and order of this Administration.