Fernando Correia’s Weblog

July 23, 2008

Cairngorm Flex client talking to Google App Engine

Filed under: Software Development — Fernando Correia @ 8:23 pm
Tags: ,

As I move forward in my project to learn about Flex and Google App Engine, I converted it to use the Cairngorm Flex framework.

My previous iteration was monolitic. Presentation, business and data access concerns where all mixed in a single source file.

This technique served my purpose to be able to see all my program in a single glance while I tried to learn how Flex worked. But this approach doesn’t scale for larger projects.

So I obviosly needed to learn how to get a better organization of a data-driven Flex application. Cairngorm was an obvious choice because it is supported and promoted by Adobe. They are even so kind as to send me periodic e-mails with tips about it!

So, I read Adobe’s introductory paper (Flex 3: Introducing Cairngorm, June 2008) and used the flex_ror_sdk_issue_tracker2 from the Ruby on Rails RIA SDK by Adobe project as an example.

In a few hours I had my application in a new structure. I even learned how to separate interface components in views, like this one:

User gestures are announced as events:

private function DeleteSelectedProjectClicked():void {
    var event:DeleteProjectEvent = new DeleteProjectEvent(dgProjects.selectedItem);

Such events are processed by commands like this:

public class DeleteProjectCommand implements ICommand
    private var __model:ModelLocator = ModelLocator.getInstance();
    private var __locator:ServiceLocator = ServiceLocator.getInstance();

    public function execute(event:CairngormEvent):void
        var project:Object = (event as DeleteProjectEvent).project;
        var service:Services = __locator as Services;
        service.gateway.call("ProjectService.delete", new Responder(onResults), project);

    public function onResults(result:Object):void {

I can see that Cairngorm is a viable alternative to build Flex applications, specially larger ones. But there are some aspects of it that seem a bit odd to me. For instance, the idea of using a big bucket of global vars as your repository for model data. And also the way I have to repeat myself creating events and commands in paralel, and having to remember to include them in the controller.

My next step will be to experiment with the PureMVC framework, an alternative to Cairngorm.

My sample project is hosted on github. It is able to show, create, update and delete projects using a service written in Python and hosted on Google App Engine. The Flex client uses the Cairngorm framework and the Python service uses the PyAMF library for communication with the client.

Please be advised that this is a learning project and does not represent a production-quality application or an example of best practices.

Feedback is welcome.

Edit: This is an ongoing project that has advanced quite a lot since this article. Browse my blog if you’re interested in learning about the progress of this example.



  1. Hi Fernando,

    Love your idea of starting a good commented pytthon-flex-cairngorm project! Very much needed indeed!

    I got your project running, there’s only one thing I do not understand just yet.

    You have 2 folders “server” and “python-client”. They contain each pyamf in its whole? Is that necsessary?
    It would help me and others much if you could explain why they are splitup in 2 seperate folders. And how the client.py knows of ProjectService.py and EchoService.py I don’t seem to get how they are linked up?

    Because I only start up “dev_appserver.py server”? And then openup the flex app.

    I have a professional background in Flex cairngorm framework and amfphp etc. More info would be veryyy welcome!

    Kindest Regards and keep on the good work and updates!

    Comment by Rien — July 25, 2008 @ 7:11 am

  2. […] — fernandoacorreia @ 8:15 am Tags: appengine, flex, python I thank Rien for giving valuable feedback on my test project. He had some questions that show I am not explaining my approach well enough. So […]

    Pingback by A few explanations about my test project « Fernando Correia’s Weblog — July 25, 2008 @ 8:15 am

  3. Rien, I answered your questions here: https://fernandoacorreia.wordpress.com/2008/07/25/a-few-explanations-about-my-test-project/

    Comment by fernandoacorreia — July 25, 2008 @ 8:16 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: