So ideally, I'd like to allow both kinds of URLs for my applications at
the same time. But the problem is that you can set only one root path in
TG using server.webpath. If you set it to "/", then the URLs
www.company.com/appname/ will not run correctly. If you set it to
"/appname", then the URLs appname.company.com will get /appname/
appended, which looks ugly and defeats the purpose of having named
virtual hosts.
One solution would be to run every application twice on different ports,
one instance with server.webpath="/" and another instance with
server.webpath="/appname", and let Apache proxy to the respective ports.
Not a really nice solution.
Another solution would be to have TG support per-host server.webpaths,
depending on the scheme and hostname that is used in the URL. This could
be implemented by allowing server.webpath to be a full URL including
scheme and hostname, e.g. "https://www.company.com/appname", and the
prefix "/appname" would be only used as webpath when the request is
using "https://www.company.com". We could also allow it to be a list
with several such URLs. It would require only some small changes in
turbogears.startup and turbogears.controllers. Anybody besides me who
thinks this is a good idea?
Or are there better solutions?
-- Christoph
Is there a reason you are not using mod_wsgi deployment to achieve above ?
Lucas
That's beside the question. Or can you show a way to solve the original
problem (running the application under two different webpaths) with
mod_wsgi?
Chris
I can see some places where I could use that. If tied together with master
templates per "root" in an easier way than today's callable solution this
could really be interesting for code reuse.
> Or are there better solutions?
I don't know. I didn't stop to think about this yet because so far all
servers that I have installed applications are dedicated servers and only
serve one domain.
--
Jorge Godoy <jgo...@gmail.com>
Godd point. Instead of server.webpath, TurboGears should regard
SCRIPT_NAME which at least 1.0 does not do. If I understand correctly,
the place where this must be fixed is the controllers.url function,
something like:
tgpath = config.get('server.webpath',
cherrypy.request.wsgi_environ.get('SCRIPT_NAME', '')) + tgpath
Maybe we should fix this even in 1.0?
-- Christoph
As Graham already commented, mod_wsgi does in fact not help since TG
does not heed SCRIPT_NAME.
However, if you use mod_proxy, then there is no way to get hold of the
original URL, so having different prefixes will not be possible on
principle (at least if you run only one instance of the application).
This was probably was Lukasz meant. (Correct me if I'm wrong.)
-- Christoph
Using this patch and mod_wsgi, you can now have both schemes
www.company.com/appname/ and appname.company.com for your application,
without setting server.webpath at all. Works nicely.
Let me know your opinion. Should we apply the patch? Or only in 1.5? Any
improvements?
-- Christoph