Is there a way to split the url mappings in multiple files in Google App Engine?
I want something like this:
from app1.controller import App1Handler
from app2.controller import App2Handler
app = webapp2.WSGIApplication([(r'/app1', App1Handler),(r'/app1', App2Handler)])
In App1Handler, I would like to specify some thing like this:
(r'/action1', Action1Handler), (r'/action2', Action2Handler)
In summary, when user access /app1/action1, Action1Handler has to be executed.
Django has a similar feature, where admin site urls are included in the main url patterns.
urlpatterns = patterns('',
url(r'^polls/$', 'polls.views.index'),
url(r'^admin/', include(admin.site.urls)),
)
Is there any such provisions available in GAE?
You can split between the 2 files at the app.yaml level:
I think you will still need to add /app1 in all your urls in the file1.py files e.g.
I think this is better because you can use handlers with the same name in the 2 modules, whereas you would get a conflict if you imported 2 handlers with the same name in a main file.