The midterms have shattered spending records for a nonpresidential contest, providing a likely blueprint for the frenzy to come when the White House is up for grabs in two years, according to political consultants, campaign-finance experts and activists from both parties.

The numbers have been driven upward in part by a proliferation of outside interest groups — particularly on the Republican side — that have taken advantage of favorable court rulings to raise and spend money more freely than in the past.

Independent groups have reported spending $270 million so far, but that number does not include tens of millions of dollars more not disclosed to the Federal Election Commission. Much of the money has been spent by nonprofit groups such as the U.S. Chamber of Commerce that do not have to reveal where they got the money.

“It’s the how-to for 2012,” said Ellen Miller, executive director of the Sunlight Foundation, which tracks money in politics. “It’s how to use corporate money, how to use secret money, to buy elections. … It’s going to be no-holds-barred.”

The rise of unfettered anonymous spending poses a serious policy and political dilemma for President Barack Obama, who has criticized the Supreme Court for deciding that corporations can spend unlimited funds on elections.

Aides and strategists close to Obama are in the midst of an intense debate over how to cope with the issue, according to sources familiar with the talks. White House officials declined to comment.

Obama discouraged independent groups from campaigning on his behalf in 2008, relying on a massive ground-level political operation to raise a record amount of money for a presidential campaign, much of it from small donors.

But Obama now faces a dramatically changed landscape in which major businesses and interest groups can raise unlimited funds, largely in secret, in support of a Republican challenger.

“My party has some collective soul-searching to do,” said Jim Jordan, a Democratic strategist who co-founded Commonsense Ten, a “super PAC” that spent about $3 million in support of Democrats this year. “Obviously we find this kind of politics distasteful. But we’ll have to ask ourselves whether our causes and constituencies are best served by disarming or by getting in the game in a more robust way.”

A customer dining at Washington’s Oceanaire restaurant noticed an unusual line at the bottom of his receipt: “Due to the rising costs of doing business in this location, including costs associated with higher minimum wage rates, a 3% surcharge has been added to your total bill.”

Three fundraising giants decided to pull events from President Donald Trump’s Mar-a-Lago Club in Palm Beach, Florida, on Thursday, signaling a direct blowback to his business empire from his comments on Charlottesville’s racial unrest.