Ahmet Recep Navruz
Ahmet Recep Navruz

Reputation: 713

web.py url handling: multiple subapplication redirection

When using web.py framework. you can redirect an url to a subapplication. e.g (code.py):

import web
import subapp1

urls = (
    "/sub1", subapp1.app,
    "/(.*)", "index"
)
....

this is really straight forward.

However, when writing subapp1.py which has its own url handlers, if i want to re-route some url, say '/sub2', to another subapplication (subapp2), i am failing.

Formerly in subapp1.py

import web
import subapp2

urls = (
    "/sub2", subapp2.app,
    "/(.*)", "some_local_class"
)
....

GET request to "/sub1/sub2/", is handled by "some_local_class" in supapp1.py. But i need this url is re-routed to subapp2.py.

Is there anything i am missing? Or may be this is not recommended url handling methodology in web.py?

Upvotes: 2

Views: 1331

Answers (1)

Ahmet Recep Navruz
Ahmet Recep Navruz

Reputation: 713

After some trial-error, found that there is nothing wrong with web.py and rerouting from subapp to another subapp. It is all working perfectly.

What is wrong is my method. Do not try to create a subapp in package's init.py file. At least when i moved subapp to its own module, it all worked well.

Upvotes: 1

Related Questions