notes.husk.org. scribblings by Paul Mison.

2010-01-24

Google App Engine notes

text 12:09:00

I’m working on a project that’s using Google App Engine’s datastore for the first time, and I seem to be learning things as I go along, so I thought I’d make a place for jottings.

  • To do a join efficiently, add a list of people an object belongs to to the object. Fetch with, eg, Objects.all().filter(‘contact_of =’, contact_of)
  • If you have a meaningful identifier (like a Flickr NSID), make that the key:
    • object = Object(key_name = id)
    • this is a cheap way to guarantee uniqueness
    • watch out, though: if you use parent() you can have duplicates
  • Fetch a key by name with object = Object.get_by_key_name(id)
    • To fetch keys only, use Objects.all(keys_only = True)
      • note this is the encoded value
      • to get the original ID back, call key.name() on the returned object
      • if you used some other identified after key_ in the put, use that instead
    • In the GAE console, you need the object type in the GQL query:
      • SELECT * FROM Object where __key__ = KEY(‘Object’, ‘key_value’)
      • generally I avoid GQL but the admin site only uses it
    • Use list comprehensions and sets intersections to find what to operate on
    • db.put() can take multiple arguments. Use this to batch datastore writes

    2009-07-26

    Heroku, App Engine, and AppJet

    text 11:04:00
    When AppJet was still around, we had an edit button, a single page of a few dozen lines and a cross-domain AJAX API. This, surprisingly enough, was all you needed to apply some programmatic patching to a bunch of different use-cases

    Jonathan Lister, from Joyent Smart Platform – a replacement for AppJet?

    In it, he compares Joyent (nee Reasonably) Smart’s model, where you develop locally then deploy with git, to that of AppJet, where you edited online via a web form.

    For a long time, I thought that the online-editing model was the right one, and I thought Heroku and App Engine suffered for not supporting it. However, when I was seriously working on my AppJet sites, I found that I ended up developing locally (with their .jar download), then wishing for an easier deployment method than copying and pasting between text files.

    For any serious project (and most developers), I’m sure that pattern would be repeated. So why bother with the complex work required to put an editor into the browser (even if Bespin promises to be a drop-in component)? Better to concentrate on the deployment side, either building on a (D)VCS like git or using custom hooks, like GAE’s “appcfg.py update”.

    He goes on to say:

    I’ve said it before and I’ll say it again – I will pay for what AppJet were providing. People will pay for what AppJet were providing.

    Unfortunately, this has a classic problem of having to build a market. Heroku can build on Rails programmers; GAE on Python and now Java developers. Smart has the harder job of getting people to write server-side JS, but at least there are people who think that way, and they can usually pick up git.

    AppJet, on the other hand, was trying to persuade people who don’t think they can program that it’s really not that hard. This is a huge problem, and I can see why it’s far easier for their developers to sell real-time web based collaboration, since everyone knows how to write words.

    I suppose this is a long winded way of saying that web-based server-side programming is still a way off.

    2008-09-14

    snaptrip: an announcement of sorts

    text 21:28:14

    I’ve finally got to the point where I’m happy to really start posting about snaptrip.

    snaptrip is a little web project that lets you use Dopplr and Flickr together. Initially, it allows you to put machine tags - specially formatted bits of data - on your Flickr photos. Why bother? Well, Dopplr itself uses this data, if available, to show you photos on its site.

    Obviously that’s a bit dull, and I do have further plans going forward, but because I’ve been stopping quite often to polish the app as I was building it, it’s been a bit slower than I’d like. (I’ve also been using it to learn about both Python and Google App Engine - the appspot.com gives that bit away).

    Anyway, once I’ve sorted out a couple of little niggles, I’ll probably post more about this elsewhere, but for now, if you have a Dopplr account, feel free to try it.

    what

    more