parametric routes

82 views
Skip to the first unread message

Scorpa

unread,
15 Feb 2018, 08:24:5915/02/2018
to web2py-users
Hello guys!


How to route some path to specific controller ?

For example, i have this in routes.py:

routers = dict(

# base router
BASE=dict(
domains={
'et.mooo.com:8000': 'sd/sea',
'127.0.0.1:8000/.we': 'sd/seb',
'127.0.0.1:8000/we': 'sd/sec',
},
default_application='menu_db',

),
)

routes_onerror = [
(r'init/400', r'/err/err')
, (r'init/*', r'/err/err')
, (r'*/404', r'/err/err')
, (r'*/*', r'/err/err')
]


Evryhing works fine with erros and default app but web2py complety ignores "domains" part.

How to fix this issue ?

Anthony

unread,
15 Feb 2018, 08:56:1315/02/2018
to web2py-users
The domains must be in the form of host:port -- it does not support any path after the port.

Anthony

Scorpa

unread,
15 Feb 2018, 09:05:1615/02/2018
to web2py-users
Then how actually re-route inside the app ?

четверг, 15 февраля 2018 г., 16:56:13 UTC+3 пользователь Anthony написал:

Anthony

unread,
15 Feb 2018, 10:14:4815/02/2018
to web2py-users
If the type of routing you want to do cannot be accommodated by the parameter-based system, you will have to use the pattern-based system (see the book section for details on how it works).

Anthony

Scorpa

unread,
16 Feb 2018, 07:03:1816/02/2018
to web2py-users
Documentation about parametric system is VERY bad and doesnt describe its abilities in. But because it's stated that parametric systems should be suffcient for all i assume somewhere i can find how to implement my solution.

For example is it able to do redirect from "/smth" which is view smth.html to controller "another.py" ?
I could not find any example of such case.

четверг, 15 февраля 2018 г., 18:14:48 UTC+3 пользователь Anthony написал:

Anthony

unread,
16 Feb 2018, 11:05:1416/02/2018
to web...@googlegroups.com
On Friday, February 16, 2018 at 7:03:18 AM UTC-5, Scorpa wrote:
Documentation about parametric system is VERY bad and doesnt describe its abilities in.

 
But because it's stated that parametric systems should be suffcient for all i assume somewhere i can find how to implement my solution.

I don't think it is stated anywhere that the parameter-based system is sufficient for all use cases. The parameter-based system was created after the pattern-based system and designed to accommodate the most common use cases in a simpler manner. The pattern-based system is for handling more complex cases.

Anthony

Scorpa

unread,
17 Feb 2018, 13:09:2817/02/2018
to web2py-users
Unfortunately this gives nothing.

Again case is very simple redirect from view named "abc" to controler "blabla".
It's not even something unusual.

пятница, 16 февраля 2018 г., 19:05:14 UTC+3 пользователь Anthony написал:

Anthony

unread,
17 Feb 2018, 14:05:0617/02/2018
to web...@googlegroups.com
On Saturday, February 17, 2018 at 1:09:28 PM UTC-5, Scorpa wrote:
Unfortunately this gives nothing.

You have already been directed to check out the pattern-based system for your needs.
 
Again case is very simple redirect from view named "abc" to controler "blabla".
It's not even something unusual.

Please read the documentation: http://web2py.com/books/default/chapter/29/04/the-core#Pattern-based-system. The very first example there does exactly what you are asking.

Anthony

Scorpa

unread,
17 Feb 2018, 16:46:5917/02/2018
to web2py-users
Thats reall frustrating because there is no details about parametric and so i need to use patterns :(

суббота, 17 февраля 2018 г., 22:05:06 UTC+3 пользователь Anthony написал:

Anthony

unread,
17 Feb 2018, 17:07:2017/02/2018
to web...@googlegroups.com
On Saturday, February 17, 2018 at 4:46:59 PM UTC-5, Scorpa wrote:
Thats reall frustrating because there is no details about parametric and so i need to use patterns :(

The problem is not a lack of details about the parameter-based system -- the link above provides fairly comprehensive documentation of it. The parameter-based system simply cannot do what you want -- so you must use the pattern-based system instead.

Anthony
Reply all
Reply to author
Forward
0 new messages