Buy a pdf version from lulu.com or a printed version from amazon.com. Published by Wiley. |
![]() |
It is possible to run web2py code on Google App Engine (GAE) (link), including DAL code, with some limitations. The GAE platform provides several advantages over normal hosting solutions:
The limitations are:
This means that web2py cannot stores sessions, error tickets, cache files and uploaded files on disk; they must be stored somewhere else. Therefore, on GAE, web2py automatically stores all uploaded files in the datastore, whether or not "upload" Field(s) have a uploadfield
attribute. You have to be explicit about where to store sessions and tickets:
You can store them in the datastore too:
1. | db = DAL('gae') |
Or, you can store them in memcache:
1. | from gluon.contrib.gae_memcache import MemcacheClient |
The absence of transactions and typical functionalities of relational databases are what sets GAE apart from other hosting environment. This is the price to pay for high scalability. If you can leave with these limitations, then GAE is an excellent platform. If you cannot, then you should consider a regular hosting platform with a relational database.
If a web2py application does not run on GAE, it is because of one of the limitations discussed above. Most issues can be resolved by removing JOINs from web2py queries and denormalizing the database.
To upload your app in GA,E we recommend using the Google App Engine Launcher. You can download the software from ref. (link).
Choose [File][Add Existing Application], set the path to the path of the top-level web2py folder, and press the [Run] button in the toolbar. After you have tested that it works locally, you can deploy it on GAE by simply clicking on the [Deploy] button on the toolbar (assuming you have an account).
On Windows and Linux systems, you can also deploy using the shell:
1. | cd .. |
When deploying, web2py ignores the admin, examples, and welcome applications since they are not needed. You may want to edit the app.yaml
file and ignore other applications as well.
On GAE, the web2py tickets/errors are also logged into the GAE administration console where logs can be accessed and searched online.
You can detect whether web2py is running on GAE using the variable
1. | request.env.web2py_runtime_gae |