Unfortunately, I am an expert on this subject by virtue of frequent trips to Mexico over many years, a relatively delicate stomach, and an adventurous palate. Fortunately, my in-laws in Mexico are doctors and so are many of their friends, so I am always surrounded by helpful experts.
In general, I have encountered three separate conditions:
1) The typical gastric distress caused by the change in intestinal flora. The cure for this is time; things like pepto-bismol which treat the symptoms until your system gets into balance are a blessing.
2) A full-blown intestinal infection, usually bacterial. You may assume this comes from eating unwashed produce or the water or the ice, etc. but you never know. Remedies such as pepto-bismol serve only to immobilize the digestive tract and do nothing to treat the underlying infection which could be getting worse as you happily eat away. Soon after the effect of the pepto-mismol wears off, you will, without question, experience the mother of all stomach explosions. This will inevitably occur on the flight home when the "Fasten Seat Belt" sign has been turned-on.

. If I get sick, I take pepto-bismol. If the stomach problems are relieved, but I still feel out of sorts, that is when I suspect something more serious.
I picked up one of these beauties on my last trip. A doctor friend took a quick look at me, made a phone call to the pharmacy down the street. Within 5 minutes some Cipro arrived. Within a few hours I was feeling human again.
3) A combination of 1 & 2: If during the transition, your defenses are weakened (dehydration, exhaustion, etc.), a bug that might not be able to become established can blossom into a full-blown infection. This was particularly a problem for me when I lived at lower altitude. The thin atmosphere, the pollution, the stress of running around preparing for the trip, the exhaustion of the travel, lots of activity upon arriving) all served to weaken my defenses. My solution is to eat lightly before travel, drink plenty of water (Mexico can be very dry), and give myself a day or two of quiet before jumping into a lot of activity. Things are much easier now that I live at high-altitude and am already accustomed to thin air.
Enjoying the cuisine of Mexico City comprises some of the most memorable moments of my life. I hope you have a great time and report back on any great finds.
Bill/SFNM