Kevin L. James, a conservative talk show host running for mayor of Los Angeles, was sitting in his campaign office recently pondering which was his bigger obstacle to victory: being openly Republican, or being openly gay. “Depending on what room you’re in here, sometimes it’s easier coming out gay to Republicans than it is coming out Republican to gays,” he said. By any measure, Mr. James, 49, is a bit of a long shot. He is a Republican brassy former prosecutor running in a Democratic city at a time when California is marching steadily to the left, making his first bid for office in a field of establishment candidates. Yet in the first major election since President Obama’s victory in November — voting that relegated the California Republican Party to the margins — Mr. James has become, at least for a few national Republicans, something of a lifeline. They see in his candidacy in the March 5 vote an outside chance to grab what could be a spirit-lifting victory, and perhaps even signal a way to get back in the game in California.