Well, i would opt for the 40D, because:
500d listprice now: 800 $
40D listprice then: 1300 $
40D price @ amazon now: 890$
And the price will definitly decrease even more very soon.
Why 40D? Well, several reasons: bigger, fits better in hand. metal body - i dont wanna miss it. better autofocus. 6 fps. shutterspeed up to 1/8000 and flash sync 1/250 (as opposed to 1/4000 & 1/200 in 500d - you will miss this in very bright situations where still wanna achieve some shallow dof). supposed to last much longer (shutter count wise). better viewfinder (brighter, bigger). there is more, but this should be enough for now.
so, what is the advantage of the 500d? well, only thing i can think of is the movie mode, which at 20fps in full HD seems crippled to me
well, maybe dataghost someday releases his video hack for the 40d, so this advantage will be "crushed" as well
btw the 50d is much more expensive right now, and is supposed to not be able to produce better pictures than the 40d, even though it has 5 more mpixel. so what you get is a massive overhead of data.
imo there is no reason not to get the 40d, at this price