-1

我正在尝试在 web2py 应用程序中实现 URL 路由方案,但并没有快速实现。我已尝试在 linux 和 Windows 上实现此处找到的示例。我在 web2py 目录而不是应用程序目录中有以下内容(这只是给定示例的重命名):

routes_in = (...,('/report', '/reporter/reporter/index'),)
routes_out = (...,('/reporter/reporter/index', '/report),)

有什么我想念的吗?这似乎应该是非常基本的。我正在运行 web2py v 2.5.1 并尝试安装 Windows 7 和 Ubuntu。

编辑:在 routes_in 和 routes_out 中定义了其他路由,这些路由作为示例提供。

4

2 回答 2

2

一个建议:如果你有很多“routes_in”元组,你可以简化 routes_out 以避免错字问题......

例如 :

# -*- coding: utf-8 -*-
routes_in = (
  (r'/', r'/myApp/pages/'),
  (r'/images', r'/myApp/images/images'),
  (r'/contact', r'/myApp/default/contact_form'),
  (r'/robots.txt', r'/myApp/static/robots.txt'),
  #A lot of stuff here...
)
routes_out = [(x, y) for (y, x) in routes_in]
于 2013-10-31T10:52:16.960 回答
0

你少了一个逗号。尝试这个:

routes_in = (('/report', '/reporter/reporter/index'),)
routes_out = (('/reporter/reporter/index', '/report'),)
于 2013-10-30T22:07:21.573 回答