> That would be truly excellent.
>
> It would change the way I do a lot of stuff. Right now I am forced to
> use php for a lot of small little apps that I don't want to surrender
> an entire web2py install for. =D
The problem is that exclusive_domain is enforced for URL(), but not for incoming requests. That's actually how it's documented:
> # exclusive_domain: If True (default is False), an exception is raised if an attempt is made to generate
> # an outgoing URL with a different application without providing an explicit host.
It's easy to extend to incoming apps, but I'd like to be sure of the rule that gets enforced. I think the rule should be: if exclusive_domain is True for a given app (either because it's set True in the base router or in an app-specific router), then that app will only recognized if the incoming domain (and possibly port) matches one mapped to that app in the domains dictionary. If it doesn't match, we'd raise a 400 invalid request/invalid application error.
BTW, you can share a web2py installation across completely separate app installs, by creating a separate applications/ directory for each app, and starting web2py with the --folder option, once for each app. I'm not sure how you'd configure wsgi for this kind of thing, but it'd be easy enough (I think) with mod_proxy.
> I read that in the documentation, but it was JUST ambiguous enough
> that I thought it might work for my uses. I can't imagine a time when
> I would want to limit it in the URL helper without also limiting the
> incoming URLs. It seems like an also-intended functionality. =)
I regard it as a bug in both the code and the documentation that needs to be fixed.
I'm looking at this logic a little more closely, and it seems to me that the current code is wrong in a way that doesn't have to do with enforcing exclusive_domain. It's easy to fix, but I wonder if someone is relying on the wrong behavior.
The problem is this. Suppose you enable domain routing thus:
domains = {
"domain1.com" : "app1",
"www.domain1.com" : "app1",
"domain2.com" : "app2",
}
Right now, domain2.com/app1 will load app1 because the code recognizes app1 as an app, and that takes priority over the domain. But that's a bug. It *should* load app2 because the domain specifies it. And in that case, "app1" in the URL will be most likely interpreted as a *function*, as it should, I believe.
That is, the domain should take priority in app determination if the domain is in the domain map, meaning that we don't really care whether "app1" happens to be the name of an app in another domain. So (unlike what I said the other day), this does not immediately result in an exception. It probably *will* result in an invalid-function exception, but that's just normal processing.
And that's why exclusive_domain is only a check on output. In fact, I'm wondering if it should be the default (or not there at all, but rather always true).
Please try the current trunk.