The Gatesgate affair may be mercifully behind us once the principals have enjoyed a beer together at the whitehouse, but it's been an instructive little summer newstorm. Your reaction to it may be taken as a pretty definitive test of your politcal leanings. Try to think back to when you first heard the story. If your reaction was sympathy for the policeman, you are an authoritarian, with a reflexive tendency to submit to authority and a desire for others to do the same. If your sympathy was with Gates, then you are a (small-l) libertarian, inclined to distrust authority and favor the individual in contests with state power. Note that this has little to do with the facts of the case. The ambiguity of the event makes it a nice litmus test.
Obama is neither of these, and I believe his unfortunate remark that the "police acted stupidly" may be explained as an interaction of these competing frames. His sympathy for the underdog (Gates) in this particular case competes with his effective role as Chief of Police (or, executive officer of the most powerful government in the world). He has no desire to delegitimize state power, but in this case the results were undesireable so it was applied "stupidly".
Of course simple racism also affects what side one falls in, but racists tend to be authoritarians, who would like nothing better for the inferior races to adopt their former subservient stance. To such people the very existence of someone like Dr. Gates is an affront.