On Oct 24, 2007, at 7:26 PM, Chris wrote:
I'm looking to accomplish the same goal as Bartlomiej (older thread below), namely, subdomains per user account and am hitting a snag.I tried the tips from an earlier post: map.sub_domains = True # TestController def index(self, sub_domain): return 'Sub = %s' % sub_domain And hitting c.localhost:5000/test (added c.localhost to my hosts file), results in Sub = None I had a few questions: What am I doing wrong?
You don't have a 'real' domain for it to find a 'sub' on. A sub- domain is XXX.domain.com. The last two parts are critical. You can supply a custom regexp to the mapper if you have an international domain (something.co.uk) so it knows how to find the subdomain there.
So c.localhost is a domain, with no 'sub' portion on it. Add localhost.com, then try something.localhost.com and something will be in the Sub section.
Does sub_domain just get passed in to every controller action implicitly every time?
Yep.
Since nearly every controller action is going to use the sub_domain to determine the correct database and so on, I feel like I should probably put this in the base controller or something?
You could, every action has it as well if it asks for it. The approach seems fine to me, and I've used it for some sites myself. Cheers, Ben
smime.p7s
Description: S/MIME cryptographic signature
