I am new to GAE and I am creating an application with the webapp framework. I was wondering when do you set handlers in your app.yaml and when you define them in your WSGI?
At first I thought you only have one main.py main file running the WSGIApplication but I notice if you want to use the GAE authorization you define that in the handlers. So that means you run multiple WSGIApplications?
I was reading the documents on "Requiring Log开发者_开发百科in or Administrator Status" and it seems they have different applications for different roles.
Maybe something like this?
-- general.py - login:
-- user.py - login: required -- admin.py: - login: adminBut maybe it's bad to have your WSGI urls spread all over the place?
If I remember correctly if you run django on GAE you point to one py file and let the framework handle everything?
I don't want to use Django yet so was wonder if anybody had some pointers/best practices on how to do url/hanlders with webapp?
Either method of URL-routing is acceptable.
app.yaml-based URL routing
If you can easily structure your app to use app.yaml routing (and authorization), then it's worth trying: it'll be less code you'll have to debug, test, and maintain.
Here's an example (from Google) with multiple entry points: http://google-app-engine-samples.googlecode.com/svn/trunk/gdata_feedfetcher/
Performance should be superior with app.yaml authorization: Your Python script won't need to be run to determine if a user is an admin of the site.
one URL-mapping table
If your app needs something beyond basic URL-routing and authorization then you may find yourself having a comparatively sparse app.yaml and using a larger URL-mapping table.
For example, you want to display a page to all users, but additionally want a "login" link to show up for an admin. This code (for a simple blog) uses this structure.
精彩评论