'checks if the current url refers to a subreddit and returns
that subreddit object.  The cases here are:
* the hostname is unset or is g.domain, in which case it
looks for /r/XXXX or /subreddits.  The default in this case
is Default.
* the hostname is a cname to a known subreddit.
On failure to find a subreddit, returns None.'

def get_subreddit(self):

    from r2.models import Subreddit, NotFound, DefaultSR
    try:
        if ((not self.hostname) or is_subdomain(self.hostname, g.domain) or self.hostname.startswith(g.domain)):
            if self.path.startswith('/r/'):
                return Subreddit._by_name(self.path.split('/')[2])
            else:
                return DefaultSR()
        elif self.hostname:
            return Subreddit._by_domain(self.hostname)
    except NotFound:
        pass
    return None
