Posts Tagged ‘Gaelyk’

A Yammer App Using Gaelyk for Google App Engine

No Comments »

I recently attended a presentation by Tim Berglund about Gaelyk at Uberconf.  The technology of Gaelyk is pretty straightforward and doesn’t need much of an introduction, especially with the excellent tutorial available on its web site.  Watching the presentation, I was struck by how little there is to Gaelyk and wondered why I was there.  Sitting in a room of developers and coding a working, useful application in just over an hour, though, reminded me about how much fun web programming can be.  Many of us have become so accustomed to frameworks like Struts, WebMVC, GWT and Grails that we’ve forgotten the simpler times, when you could slap together some Servlets and JSPs and have fun putting together a small, useful app.  Gaelyk brings back those simpler times and makes them even more enjoyable by adding the conveniences of Groovy and App Engine.

I picked an app that I wanted to code, something that would tell Yammer users what their companies are talking about.  It’s available for anyone to use at http://whatyammer.appspot.com.

Data access

Want to save a record to the database?  Forget about messing around with bean and data access classes, database connections and ORM.  No need to create tables.  You’re coding for fun!

def user = new Entity('user')
user.email = params.email
user.name = params.name
user.phone = params.phone
user.save()

That’s all.  To get that record back out

datastore.execute {
  select single from user
  where email == params.email
}

Forwarding objects to a view

Gaelyk views are coded in gtpl files, which are much like JSPs. The controller, echo.groovy

request.users = datastore.execute { select all from user where email == params.email }
forward 'showusers.gtpl'
The view, showusers.gtpl
Adventure Time with <%= (request.users*.name).join(' and ') %>
That prints the names of all users, with the word and between each one.  That is just a small taste of what Gaelyk makes available.  So simple!  So much fun!  Single-command deployment!  Google will host 10 apps for free, so there isn’t any reason not to try it out.  Just note that before you deploy, you have to visit http://appengine.google.com and register your new app or Google will give you a very unhelpful error message.