塔/路由 命名路由与关键字路由和子域
子域行为在我的 Pylons 项目中没有按照我的预期工作。有人可以提供一些见解吗?我正在使用命名路由并收到一个不包含当前子域的 URL:
我在映射器上定义了以下规则:
map.sub_domains = True
...
map.connect('openid_verify', '/verify', controller='oid',
action='verify')
在我的控制器中,我放置了以下两行代码:
print url('openid_verify')
print url(controller='oid', action='verify')
我希望这两行始终打印同样的东西。但是,当我访问主机“sub.localhost.local:8080”时,我得到以下输出:
http://localhost.local:8080/verify
/verify
为什么命名路由完全限定了错误的主机?查看 request.environ 字典清楚地表明我正在访问子域。以下代码也可以正确打印出主机:
from routes import request_config
...
r = request_config()
r.load_wsgi_environ(request.environ)
print r.host
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前尚不清楚是什么原因造成的,但可能有解决方法。您是否尝试过给 url() sub_domain 参数?
It's not clear what's causing that, but there may be a workaround. Have you tried giving url() a sub_domain argument?