It was as if the fates had conspired to give Barack Obama the kind of foreign affairs photo op that a campaign manager would see only in his wildest dreams. Damp, gray Berlin was alive with bright sunshine. A crowd that police estimated at more than 200,000 filled the heart of the city. It cheered not only when he talked about global warming or called for a world without nuclear weapons, but also when he spoke of the fight against terrorism and the need for Europe to remain engaged in Afghanistan and Iraq.

“In Europe, the view that America is part of what has gone wrong in our world, rather than a force to help make it right, has become all too common,” Obama chided — and Berlin took the admonishment in stride. What were the odds against that?

There has been much comment about the extraordinary luck that has followed Obama’s new Boeing 757 around the globe like an escort plane. Indeed, from the Obama campaign’s point of view, it would be hard to script a better series of set pieces. He lands in Afghanistan just as Allied commanders and even Bush administration officials endorse his view that more U.S. forces are needed there urgently. He moves on to Baghdad, and Iraqi officials promptly echo his call to set a timetable for U.S. withdrawal. He tiptoes through the minefield of the Israeli-Palestinian conflict and somehow comes out unscathed.

After all this good fortune, the Berlin stop became more like a state visit than a political foray. The huge media contingent traveling with Obama, lacking gaffes or controversy to grill him about, was reduced to asking how it felt to be welcomed by cheering multitudes whose hosannas would embarrass a conquering hero.

The Roman philosopher Seneca said it best, of course: “Luck is what happens when preparation meets opportunity.” Legendary movie mogul Sam Goldwyn was even pithier: “The harder I work, the luckier I get.”

Obama has been talking about the need to pay more attention to Afghanistan — and to schedule a pullout from Iraq — for more than a year. His enthusiastic welcome in Berlin owed much to the way he has made restoring America’s image in the world a major theme of his campaign. Obama helped make the good luck that he’s now enjoying.

Bad luck is a different thing, however. As Franklin Roosevelt once said, “I think we consider too much the good luck of the early bird and not enough the bad luck of the early worm.”

John McCain is having an “early worm” kind of week. It’s not just that he goaded Obama into taking his trip. And it’s not just that the world’s attention has been focused on the Obama trip, while McCain’s plane was met in New Hampshire the other day by only one reporter.

It’s also that McCain’s attempt to capitalize on one of his most promising issues — energy prices — while Obama was preoccupied with foreign affairs has seemed jinxed. The McCain campaign had the idea of helicoptering the candidate to an oil platform in the Gulf of Mexico, to highlight his support of eliminating the ban on new offshore drilling. But Hurricane Dolly made the trip dicey — and a barge accident in New Orleans that spilled 420,000 gallons of fuel oil into the Mississippi River made it even dicier. A big, noxious oil spill was not the backdrop McCain wanted. He ended up making a hastily scheduled campaign appearance at a grocery store — not quite the same thing as commanding the world stage from the Victory Column in Berlin.

But a run of bad luck doesn’t justify McCain’s increasingly angry rhetoric. His new attack line is that Obama “would rather lose a war in order to win a political campaign” — a stunning charge to level against a fellow U.S. senator, and perhaps a reflection of McCain’s frustration at having failed so far to paint Obama as some kind of geopolitical naif.

If the grouching and grumbling continue, a campaign that once promised to be a referendum on Barack Obama’s experience threatens to become a referendum on John McCain’s temperament. At the moment, one of the candidates is acting presidential and one isn’t.

McCain’s crankiness toward Obama reminds me of something the French writer Jean Cocteau once said: “Of course I believe in luck. How otherwise to explain the success of those you dislike?”

Eugene Robinson’s e-mail address is eugenerobinson(at)washpost.com.

© 2008, Washington Post Writers Group

Your support is crucial…

With an uncertain future and a new administration casting doubt on press freedoms, the danger is clear: The truth is at risk.

Now is the time to give. Your tax-deductible support allows us to dig deeper, delivering fearless investigative reporting and analysis that exposes what’s really happening — without compromise.

Stand with our courageous journalists. Donate today to protect a free press, uphold democracy and unearth untold stories.

SUPPORT TRUTHDIG