Make passing a subdomain to reverse() optional, and allow for a configurable get_domain_for_request

If no subdomain is passed to reverse, iterate over the urlconfs for each subdomain and use the first matching route.

Also, store the base domain in thread local storage on request and allow for a configurable get_domain_for_request. This allows for a customized way to determine the base domain from the HTTP Host header that is available within reverse() without passing the request around.