我正在使用带有 pylons 的标准路由模块来尝试为我的网站主页设置默认路由。
我已经按照文档和此处http://routes.groovie.org/recipes.html中的说明进行操作,但是当我尝试时,http://127.0.0.1:5000/
我只是得到了“欢迎来到 Pylons”的默认页面。
我的 config/routing.py 文件看起来像这样
从 pylons 导入配置 从路由导入 Mapper
def make_map():
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
always_scan=config['debug'])
map.minimization = False
map.connect('/error/{action}', controller='error')
map.connect('/error/{action}/{id}', controller='error')
# CUSTOM ROUTES HERE
map.connect( '', controller='main', action='index' )
map.connect('/{controller}/{action}')
map.connect('/{controller}/{action}/{id}')
return map
我也试过 map.connect('/', controller='main', action='index')
和(使用http://127.0.0.1:5000/homepage/
)
map.connect( 'homepage', controller='main', action='index' )
但根本没有任何作用。我知道它正在重新加载我的配置文件,因为我使用 paste serve --reload development.ini 来启动服务器
系统信息
$ paster --version
PasteScript 1.7.3 from /Library/Python/2.5/site-packages/PasteScript-1.7.3-py2.5.egg (python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12))