What and whom this book is for
Google App Engine has a simple architecture: you upload files to it and GAE serves HTTP requests. That's pretty much all it does. Google Cloud SQL is a customized version of MySQL you can use from any server, including GAE.
This book aims to take the web2py programmer through every step required to develop, debug, and deploy web2py apps on Google App Engine, using Google Cloud SQL as the backing database.
Advantages using using web2py with Google App Engine and Google Cloud SQL
This document is intended for developers who wish to create pretty standard line of business applications backed by a SQL database. Web2py, GAE and Google Cloud SQL are a powerful solution. Here's why and why not this specific configuration may work for you.
Good things about this approach:
Virtually no sysadmin work required! Once you've learned how to deploy your application, you won't need to do any operating system updates, penetration testing, operating system configuration, or security testing (other than the level of security your app provides--and web2py used properly is exceptionally secure) About the only thing you need to do is watch the dashboard and check your billing stats
Free scalability: If your site gets so busy that it nees more resources, they're applied as needed. If it gets less busy, they're removed. You are only billed for what's needed, and it's very inexpensive for small to medium sites
Extreme simplicity... once you know what you're doing If you're new to deploying websites, there are lots of little gotchas and that's what this book is meant to do: help you learn the things that all the folks at Google, MySQL, and web2py think you already knew, but didn't. When you finally get a clear view of the whole process, it's easy to keep the whole thing going without having to hire a system administrator
Free data protection Google Cloud SQL automatically encrypts data as it's stored, and decrypts as you use it. You need do nothing for this to happen (and in fact you cannot stop it from happening). It's fantastic to be able to tell clients and other users of your app that their data is encrypted, and that Google is responsible for it
Simple, free version management GAE automatically retains your 10 most recent deployments, so you can roll back to a previous version in an instant
Possible disadvantages using the GAE/Cloud SQL/web2py stack
Sandboxed! Some common operations must be replaced Want to open a text file and write to it to the local file system? You can't. The App Engine file system is read-only. Want to use common image manipulation libraries? Nope. The reason is that apps running on GAE are sandboxed, meaning many common operating system features such as writing to the local file system, creating threads, and other resource management is handled by the host, GAE in this case. What you get in return is free scalability, zero system administration, improved security, and much greater flexibility in deployment.
No control over the operating system: Read the GAE documentation and after a while you'll notice that there is no mention of the host operating system. That's because you have no access to its internals. It is nothing more than an execution environment.
Python 3.0 not yet supported At time of writing, only Python 2.5 and 2.7 are supported
December 2015: Unfinished
This book is about 50% completed and not ready for prime time. Many of the linked sections are usable--browse through them quickly to get a feel before you take them seriously. Some, such as the chapter on unit testing, are placeholders.
If you're a busy web2py developer, new to devops/deployment on Google App Engine (GAE) or Google Cloud SQL, and are always in the middle of several projects, this book is for you. It takes a thorough step-by-step approach with every line of a complete, working web2py project from your local machine to deployment on Google App Engine on its own domain, with no "exercises left to the reader".
web2py makes it mind-blowingly simple to create robust, complex, easily-to-maintain database applications. Actually getting those applications deployed to Google App Engine is full of details that don't really belong in the Massimo di Perro's wonderful web2py book, but without clear, accessible documentation those details can cost days or weeks of frustration for the first time Google App Engine or Google Cloud SQL users.
Likewise, if you're new to database administration or would like specifics regarding Google Cloud SQL, you'll find plenty of details not otherwise found in Google's documentation, which seems to assume you've deployed database apps and are already familair with GAE.
These details are so numerous that they can fade quickly from your mind, especially when you're busy just trying to keep your app running and add new features without breaking old ones.
At the moment, the book assumes you:
- Know some python
- Know a little about web2py
- Went through the git tutorial
- For the moment, are running OSX on your development machine. There are some command-line examples I haven't yet ported to Windows and Linux, but if you can get past those the vast majority of this book is useful know matter what platform your development machine runs. If you're not running OSX and have trouble with these examples, contact me.
- Can afford a Google Cloud SQL account, because there is no free tier. The cost of a new account you can use for this book is about the cost of lunch at a fast food restaurant but does require a credit card
- Optionally: Have access to a domain name you can point to your application
Dangers of using this book
This course uses a cookbook approach, emphasizing complete step by step instructions and illustrations for everything it covers. But it also explains the concepts behind each step first. The value of this version of the book will decay over time as Google changes its user interface or product lineup.
By explaining each step of the way, I tried to mitigate problems causes by the inevitable changes in UI over the coming months.
What it covers
- Installing web2py from source on your machine
- Creating a Google App Engine Account
- Creating a Google Cloud SQL database
- Installing the Google App Engine SDK
- Deploying web2py itself to Google App Engine
- Creating a sample web2py application to manage tasks
- Creating unit tests, a necessary step to ensure your Cloud SQL database indexes are created properly.
- Deploying your web2py application to Google App Engine
- Connecting a domain name to your web2py application
- Putting your web2py application under version control
- Putting web2py itself under version control