Fernando Correia’s Weblog

July 15, 2008

Flex and Python project

Filed under: Software Development — Fernando Correia @ 1:26 pm
Tags: , ,

I am working on a project to learn how to use Google App Engine. This is the architecture:

The client will use Adobe Flex to have a rich interface without the hassle of dealing with differences in the implementation of HTML, CSS and Javascript between browsers. The server will be a Python service on Google App Engine. The client will talk to the server using AMF encoded messages over HTTP. If possible, using a RESTful convention.

The goal of this experiment is to create a Web application with a rich user interface and a fast response time in a high-performance server environment without worrying too much about server administration.

The flex-and-python-test project is available in github.

Some highlights of the source code:


import wsgiref.handlers
from pyamf.remoting.gateway.wsgi import WSGIGateway
from services import EchoService, ProjectService

services = {
    'EchoService': EchoService.EchoService,
    'ProjectService': ProjectService.ProjectService,

def main():
    application = WSGIGateway(services)

if __name__ == '__main__':


class EchoService:
    def echo(self, data):
        return data;

    def echo_upper(self, data):
        return str(data).upper();


from pyamf.remoting.client import RemotingService

gw = RemotingService('http://localhost:8080/')

print "Testing EchoService:"
service = gw.getService('EchoService')
print service.echo('test')
print service.echo_upper('test')
print service.echo_upper(1)

print "Testing ProjectService:"
service = gw.getService('ProjectService')
print service.get(1)
print service.get_all()


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="remoteObj" endpoint="http://localhost:8080/"
  result="resultField.text = event.toString(); outputField.text = event.result.toString();"
  fault="resultField.text = event.toString()"/>
  <mx:Label x="10" y="10" text="Input:"/>
  <mx:TextInput x="70" y="10" id="inputField"/>
  <mx:Button x="238" y="10" label="Submit" click="remoteObj.echo_upper(inputField.text)"/>
  <mx:Label x="10" y="42" text="Output:"/>
  <mx:TextInput x="70" y="40" width="652" id="outputField" editable="false"/>
  <mx:Label x="10" y="71" text="Result:"/>
  <mx:TextArea x="70" y="70" width="652" height="332" id="resultField" editable="false"/>

The first version of this project is working. The next stop will be model objects.

Edit: This project is now finished. You can see the final result in this article.



  1. Have you looked at the “GAE SWF” project?


    He’s able to do deep linking and intelligent redirect after login…

    Comment by evolvingtrends — July 16, 2008 @ 3:47 am

  2. Interesting! I’m looking forward to future blog entries related to GAE, PyAMF and flex.


    Comment by Marcel Overdijk — July 16, 2008 @ 6:55 am

  3. evolvingtrends: I am aware of the GAE SWF project and I plan to dig deeper into it.

    Marcel: Thanks for your support!

    Comment by fernandoacorreia — July 16, 2008 @ 7:56 am

  4. Have you had any luck doing this passing real objects over PyAMF? The echo interface is definitely a good first step, but this becomes a lot more interesting when you are sending real objects and using them in ActionScript. That’s the part I could not make work in any seamless way without mapping all the Python object properties to methods in a service class.

    Comment by HG — July 16, 2008 @ 11:07 am

  5. HG: That will be my next step. As you realized, I wanted to build a minimum functionality proving that communication works first. I will try to find out how to pass objects and object collections, and also how to deal with RESTful requests.

    Comment by fernandoacorreia — July 16, 2008 @ 12:49 pm

  6. […] fernandoacorreia @ 9:50 pm I advanced another step on my Flex and Python Test project. Now it is able to insert new objects in the data store and to retrieve […]

    Pingback by Fernando Correia’s Weblog — July 16, 2008 @ 9:50 pm

  7. I’ll be interested to see how this goes. Our inhouse Flex developer, Jay Wood, has been using django with djangoAMF. We have considered using pyAMF, but just haven’t had the time to jump into it.

    Comment by Brain Cragin — July 17, 2008 @ 12:46 pm

  8. Brian: Thank you for the encouragement. There is now an update at https://fernandoacorreia.wordpress.com/2008/07/16/22/

    Comment by fernandoacorreia — July 17, 2008 @ 1:12 pm

  9. […] Development — fernandoacorreia @ 10:29 pm Tags: flex appengine In a new iteration of my Flex and Python Test project, I created a crude Flex client. It is able to talk to the GAE server using AMF and perform two […]

    Pingback by Flex client talking to GAE « Fernando Correia’s Weblog — July 17, 2008 @ 10:29 pm

  10. […] flex, python I am continuing to learn how to integrate Flex to Google App Engine. Now my test project is able to update objects, in addition to inserting and retrieving […]

    Pingback by Flex client updating objects in Google App Engine « Fernando Correia’s Weblog — July 19, 2008 @ 10:31 pm

  11. […] Development — fernandoacorreia @ 8:23 pm Tags: appengine, flex As I move forward in my project to learn about Flex and Google App Engine, I converted it to use the Cairngorm Flex […]

    Pingback by Cairngorm Flex client talking to Google App Engine « Fernando Correia’s Weblog — July 23, 2008 @ 8:23 pm

  12. […] under: Software Development — fernandoacorreia @ 8:42 pm Tags: flex, puremvc Continuing my quest to build a Flex client to a Python service on Google App Engine, I decided to try converting my […]

    Pingback by Flex client using PureMVC « Fernando Correia’s Weblog — July 30, 2008 @ 8:42 pm

  13. […] — fernandoacorreia @ 9:45 pm Tags: appengine, flex, python I’m making progress on my endeavor to build a Flex client to a Python service hosted on Google App […]

    Pingback by Flex with GAE: adding participants to projects « Fernando Correia’s Weblog — August 13, 2008 @ 9:45 pm

  14. […] Flex and Python project […]

    Pingback by Example of RIA in the cloud « Fernando Correia’s Weblog — August 23, 2008 @ 12:34 pm

  15. All this talk about a service hosted on Google app Engine sound great, but what if you just want to use Flex and Python with pyamf to retrieve data from a server?
    I am new to this so it is a bit mind numbing at times.
    Do you have an example of using RemoteObject to get data from the server using python and mysql. I want to be able to use the PYAMF format because it is faster than just XML.
    I am looking for an example I can use and then apply to what I need to do. 1st retrieve the data and populate a grid with it and then Insert, Modify and Delete functions. The basics to any application. Once i have this then I can build on that.

    Thank you,

    Comment by Roger Ross — February 18, 2009 @ 2:39 pm

  16. GoogleAppEngineとFlashでの通信を別のファイルにする…


    + MyProject
    – main.py
    – app.yaml

    Trackback by taichino.com — July 31, 2009 @ 5:55 am

  17. Greg Mendel is also, by huge coincidence, the name of the Augustinian monk who is credited with being the father of modern genetics. ,

    Comment by Roy34 — October 22, 2009 @ 5:40 am

  18. doors.txt;1;2

    Comment by brGVSGNGDi — November 16, 2009 @ 2:36 pm

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: