开发者

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"
)
....
开发者_JAVA技巧

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜