所有控制器的web2py路由?

时间:2014-05-28 12:34:00

标签: python mod-rewrite url-routing web2py

我想要这样的东西使用web2py路由:

  • domain.com/App/controller/view/args?profile Id = XX
  • domain.com/App/profile Id / controller / view / args

我试试这段代码:

routes_in = (
    ('/App-name/(?P<any>.*)/$c/$f/', '/App-name/$c/$f/\g<any>'),
)
routes_out = (
    ('/App-name/$c/$f/\g<any>', '/App-name/(?P<any>.*)/$c/$f/'),
)

谢谢

1 个答案:

答案 0 :(得分:1)

现在的工作

routes_in = (
('/admin','/admin'),
('/admin/$anything','/admin/$anything'),
('/$app/appadmin','/$app/appadmin'),
('/$app/appadmin/$anything','/$app/appadmin/$anything'),
('/Appname/$profileid/','/Appname/default/index/$profileid'),
('/Appname/$profileid/$c/$f/','/Appname/$c/$f/$profileid'),
('/Appname/$profileid/$c/$f/$arg1','/Appname/$c/$f/$arg1/$profileid'),
('/Appname/$profileid/$c/$f/$arg1/$arg2','/Appname/$c/$f/$arg1/$arg2/$profileid'),
)
routes_out = (
('/admin','/admin'),
('/admin/$anything','/admin/$anything'),
('/$app/appadmin','/$app/appadmin'),
('/$app/appadmin/$anything','/$app/appadmin/$anything'),
('/Appname/default/index/$profileid','/Appname/$profileid/'),
('/Appname/$c/$f/$profileid','/Appname/$profileid/$c/$f/'),
('/Appname/$c/$f/$arg1/$profileid','/Appname/$profileid/$c/$f/$arg1'),
('/Appname/$c/$f/$arg1/$arg2/$profileid','/Appname/$profileid/$c/$f/$arg1/$arg2'),
)