Wednesday, March 25, 2009

Google App Engine

I'm learning more about cloud computing this morning. Hey, YouTube is coded in Python, didn't know that.

J.C. Gregorio is taking us through the app.yaml file (don't use /_ah/ or /form). You fall through the rule set. List the top level handlers, what to skip, caching rules. Not everything in your tree has to be mentioned though. Specify whether a login is required and, if so, must it be admin.

Django 0.96 is the current default templating language, but you're not forced to use it. Use os.path.dirname(__file__) to build an absolute path to our template file. We're getting questions about using Mako instead of Django. I found some stuff in the blogs about that. What about Jinja2?

Lars is here from the Mozilla development team. He's been working on a crash detector that phones home (sends httpRequest) with a binary payload, with Python doing the analysis on the server. Mozilla is able to monitor, in quasi-real time, where their browser is breaking.

Read PEP 333 to get a better handle on WSGI, which supersedes CGI. The SDK includes a lightweight version. We're moving quickly here, as the datastore is what's most important.

The datastore is an "entity store". It's not an RDBMS. You can't do joins. GQL is the new language, based on SQL but different. Subclass db.Model and create your properties, setting defaults (e.g. auto_now_add=True for db.DateTimeProperty). The writes probably take longer than you're used to, given the redundant write stipulations (like the Hadoop, you'll have x3 replication). Update the same entity about 5 times a second, but as many entities as you like in parallel. Reads are very fast.


I got stuck trying to store and read the above GIF in a model blob property, couldn't get it to work. The famous Wesley Chun in the row in front came back and showed me his solution (he liked the challenge, which I'd asked about publicly). He knew some tricks it'd've taken me a long time to come up with (set mime-type, use read method). Thx! I hope he sends me the source code (note later: he did).

Mozilla Guy
Cowboy Programmer
(K.L.L., Mozilla Corporation)