Friday, 15 June 2012

python - Run code before url mapping on google app engine -


I first want to see datastore, to see if there is any data, and if not, redirect on the other Do page (most likely / admin>) ) However, I do not already want to overwrite the url mapping framework there.

Is there a way to set up a handler that will process all requests before mapping all?

I am using Google App Engine with Python 2.7 and WebAP 2.

Yes, you can do it with custom classes. In the example shown in this link, the new class name is MyHandler . This means that all your request sections need to be obtained from MyHandler instead of webapp2.RequestHandler . Since this will be implemented by you, you can call your code before sending () webapp2.RequestHandler.dispatch (self) . In other words, you probably want to change webapp2.RequestHandler anyway.

No comments:

Post a Comment