one webapp project has many url
and i have to change this:
('/addTopic', AddTopic),
('/delTopic', DeleteTopic),
('/addPost', AddPost),
('/delPost', DeletePost),
to this:
('/tribes/addTopic', AddTopic),
('/tribes/delTopic', DeleteTopic),
('/tribes/addPost', AddPost),
('/tribes/delPost', DeletePost),
but ,if i add this to my project ,i have to change the url in every py file or html file ,
in django
it can be this :
urlpatterns = patterns('',
(r'^articles/2003/$', 'news.views.special_case_2003')),
)
it is easy to add the url of 'news' to my peoject,
but does webapp has this ?
thanks
updated:
(1) my main page url is :
('/', MainPage),
('/sign', Guestbook),
(2) the url of a webapp project that i want to add is :
('/', MainPage),
('/logout', LogoutPage),
('/login_response', LoginHandler),
and i want to change (1) to this:
('/', MainPage),
('/sign', Guestbook),
('/aa/', p2.MainPage),
('/aa/logout', p2.Logo开发者_如何学CutPage),
('/aa/login_response', p2.LoginHandler),
so i have to change so many url like / to /aa/ , or change /logout to /aa/logout
in py file and html file , that is a hard work
so any simple way to do this ?
I think I understand what you're trying to do. URL routing is pretty flexible. When the request comes in, the URL is matched against your list of handlers to determine which python script is invoked. If you're using webapp, the URL gets matched against a second list of regexes to determine which class handles the request.
Let's say your app.yaml looks like this:
handlers:
- url: /foo/.*
script: foo.py
- url: /bar/.*
script: bar.py
Inside bar.py, you have this:
('/[^/]+/', MainPage),
('/[^/]+/logout', LogoutPage),
('/[^/]+/login_response', LoginHandler)
Those regex prefixes should match URLs that start with a slash, are followed by one or more characters that are not a slash (any subdirectory name), and then have another slash followed by the rest of the URL.
If a request comes in for /bar/logout, app.yaml will match it to the /bar/.* regex and pass it to bar.py, and bar.py will match it to the /[^/]+/logout regex and pass it to LogoutPage.
If you decide you want the subdirectory to be "baz" instead of "bar", you can change the url in app.yaml and potentially leave the rest intact.
I'm not quite sure I understand what you're asking. URL patterns in webapp are regular expressions, and they're evaluated in order, first to last. You can include captured groups in the regex, and they will be extracted and passed as arguments to the handler. For example:
('/articles/2003/(.*)', Articles2003),
('/articles/(\d+)/(.*)', Articles),
精彩评论