Virtual Hosting routes using composite application

32 views
Skip to first unread message

Jason

unread,
Sep 2, 2011, 1:53:41 PM9/2/11
to pylons-...@googlegroups.com
HelIo,

I've got a composite application using urlmap with two applications on different url prefixes. The documentation for virtual hosting at https://pylonsproject.org/projects/pyramid/dev/narr/vhosting.html doesn't say what I need to do to have my routes generate the correct URL.

When I use request.route_path or request.route_url it always gives me a url without the prefix /pyramidapp. But if I add /pyramidapp to the route's pattern or I use config.include with route_prefix=pyramidapp then no incoming routes match because urlmap passes everything after /pyramidapp as the path. 

Is there a step I missed to tell the route generation that I am using urlmap to do virtual hosting?

As an alternative: is there a way to tell url map to use subdomains for virtual hosting (I use route_path for url generation)?
It looks like the urlmap function can do it (http://pythonpaste.org/modules/urlmap.html) but I don't see how to do that in the config file.

Thanks for the help,

Jason

Jason

unread,
Sep 2, 2011, 2:22:42 PM9/2/11
to pylons-...@googlegroups.com
I browsed the urlmap source code to find that this can be entered into the config file to use a subdomain for url mapping:

[composite:main]
use = egg:Paste#urlmap
domain app1.localhost = app1pipe 
domain app2.localhost = app2pipe

It's less than ideal because I would like to use a path to specify the application, but it will work. Rumour has it I will also have to include the ProxyPreserveHost directive in my Apache config (I'm using mod proxy in the production deployment).

--Jason

Jason

unread,
Sep 22, 2011, 4:26:01 PM9/22/11
to pylons-...@googlegroups.com
I have figured out the problem. urlmap sets the script name appropriately and then I was using PrefixMiddleware in the application pipeline that was resetting the  script name environment variable to '/'.

--Jason
Reply all
Reply to author
Forward
0 new messages