Starts the program in a way that will work with Google app engine, no matter which version you are using (2.5 / 2.7) If it is 2.5, just normally start it with app.gaerun() If it is 2.7, make sure to change the app.yaml handler to point to the global variabl
(self, *middleware)
| 379 | return wsgiref.handlers.CGIHandler().run(wsgiapp) |
| 380 | |
| 381 | def gaerun(self, *middleware): |
| 382 | """ |
| 383 | Starts the program in a way that will work with Google app engine, |
| 384 | no matter which version you are using (2.5 / 2.7) |
| 385 | |
| 386 | If it is 2.5, just normally start it with app.gaerun() |
| 387 | |
| 388 | If it is 2.7, make sure to change the app.yaml handler to point to the |
| 389 | global variable that contains the result of app.gaerun() |
| 390 | |
| 391 | For example: |
| 392 | |
| 393 | in app.yaml (where code.py is where the main code is located) |
| 394 | |
| 395 | handlers: |
| 396 | - url: /.* |
| 397 | script: code.app |
| 398 | |
| 399 | Make sure that the app variable is globally accessible |
| 400 | """ |
| 401 | wsgiapp = self.wsgifunc(*middleware) |
| 402 | try: |
| 403 | # check what version of python is running |
| 404 | version = sys.version_info[:2] |
| 405 | major = version[0] |
| 406 | minor = version[1] |
| 407 | |
| 408 | if major != 2: |
| 409 | raise OSError("Google App Engine only supports python 2.5 and 2.7") |
| 410 | |
| 411 | # if 2.7, return a function that can be run by gae |
| 412 | if minor == 7: |
| 413 | return wsgiapp |
| 414 | # if 2.5, use run_wsgi_app |
| 415 | elif minor == 5: |
| 416 | from google.appengine.ext.webapp.util import run_wsgi_app |
| 417 | |
| 418 | return run_wsgi_app(wsgiapp) |
| 419 | else: |
| 420 | raise OSError("Not a supported platform, use python 2.5 or 2.7") |
| 421 | except ImportError: |
| 422 | return wsgiref.handlers.CGIHandler().run(wsgiapp) |
| 423 | |
| 424 | def load(self, env): |
| 425 | """Initializes ctx using env.""" |