开发者

Pylons/Routes Named Routes vs. Keyword Routes and Subdomains

Subdomain behavior is not working as I expect in my Pylons project. Can someone provide some insight? I was using a named route and received back a URL that did not contain my current subdomain:

I have the following rule defined on my mapper:

    map.sub_domains = True
    ...
    map.connect('openid_verify', '/verify', controller='oid',
    action='verify')

In my controller, I put the following two lines of code:

    print url('openid_verify')
    print url(controller='oid', action='verify')

I would expect those two lines to always print the same thing. However, when I visit the host 'sub.localhost.local:8080', I get the following output:

    http://localhost.开发者_如何转开发local:8080/verify
    /verify

Why is the named route fully qualified with the wrong host? Looking in the request.environ dict clearly shows that I am visiting a subdomain. The following code also correctly prints out the host:

    from routes import request_config
    ...

    r = request_config()
    r.load_wsgi_environ(request.environ)
    print r.host 


It's not clear what's causing that, but there may be a workaround. Have you tried giving url() a sub_domain argument?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜