I usually don't recommend my way of doing things like this. Lots of times I get criticized for wanting to do too much work, for being too 'anal' about things, or doing things the hard way.
Since you asked: After the whole car is in final primer, and ready to hang all the sheetmetal, I final sand, and paint the jams in the color I'm using for a base, say silver for candy or white for pearl. Lock it down with an intercoat clear (NON catalyzed). Now assemble the car, final sand it, paint it. DO NOT mask the jams and edges! Usualyl, after shooting the last coat of base color, I take a Scotchbrite pad, and clean up the excess base in the jams and edges.
After the outside is painted, and letting it cure for a week or so, but before I sand and buff, I remove the doors (the only way to get jams looking great!). I have a floor jack I converted to a door holder, so I can do the job by myself. I drill the hinges, with a 1/8" drill bit, so I can insert a 1/8 welding rod in them when I re-assemble, and have them in the exact right place. You can do this with the trunk and hood, if you like, but usually I spray the underside of the trunk first, then tape it off, not as critical because of it's sharp edges.
As for the painting...the jams are already in base color. Sand the intercoat clear, being careful not to disturb the candy color that fogs its way into the jams. You can lightly Scotchbrite them to scratch them up for paint adhesion. Use those fogged edges to blend your color into the jam. I use the same candy paint, but add candy concentrate into it, so I don't have to put on the same amount of coats to achieve the same color. You don't want too thick paint on your edges! Even if the color is a bit "off", darker or lighter, it usually doesn't show in the jams, but get it as close as you can. After getting your candy color in, back tape off the body and clearcoat the jams. Any little bit of clear that makes it's way onto the body ( and you want this, so the jams are clean right up to the edge of the body) will get sanded off when you sand the body to buff it out.