Arnie Riebli is president of Sunrise Farms, which delivers about a million eggs a day to stores in Northern California.

Sunrise is one of two big egg producers left in a community that once had 2,700 and called itself the Egg Basket of the World.

"We saw opportunity where everyone else saw challenge," Riebli told The Press Democrat Editorial Board during a visit to his Petaluma farm.

Riebli's explanation for his perseverance is also an apt description of the strange bedfellows alliance of animal welfare advocates and egg farmers backing federal legislation to improve conditions for hens and level the playing field for producers.

The measure, introduced in the House with bipartisan support, is an upshot of Proposition 2, a ballot measure banning the use of cramped cages on California egg farms.

Passed in 2008, it requires farmers to stop using cages that prevent hens from turning around or stretching their wings. The new rules take effect in 2015.

California is the fifth largest egg-producing state, according to the American Egg Board, and it's the largest to outlaw so-called battery cages.

Egg farmers opposed Proposition 2, warning that new barns and new cages would cost millions, leaving them unable to compete with farms in Mexico and other states that aren't bound by the same rules. We also opposed Proposition 2, citing the impact on one of Sonoma County's trademark industries.

But the measure passed with a 63 percent majority, a strong expression of public expectations of humane conditions for farm animals. As further evidence of those expectations, a growing number of restaurant chains, food producers and retailers are switching to cage-free eggs. A list published by the Humane Society of the United States includes General Mills, Kraft, IHOP, Subway, Wal-Mart, Safeway and others. The European Union also has outlawed battery cages.

To assist the state's farmers, California legislators passed a law prohibiting the sale of any eggs that aren't produced using the practices required by Proposition 2.

But the trend in public opinion is clear, and the United Egg Producers, which represents 88 percent of the nation's producers, was wise to negotiate a national deal with the Humane Society, the primary sponsor of Proposition 2.

"It's been a long time coming," Riebli said. "We've seen millions of dollars spent by both sides."

There are shortcomings in the proposed legislation. For starters, egg farmers in the rest of the country would have until 2029 to replace battery cages with larger colony cages, while the 2015 deadline in Proposition 2 would still govern California farmers.

There also are significant political obstacles, starting with cattlemen and other livestock interests who oppose the bill.

But the same organizations successfully challenged a California law governing slaughterhouses, arguing in court that federal standards should prevail. Fair enough, let the same approach extend to egg farms.