RecordSet

Introduction

This page describes how to setup the RecordSet Adobe Flash (MX 2004) example application.

Installation

First you need to install the free Flash Remoting components for Adobe Flash MX 2004 or Flash 8.0.

If you want to use Flash Remoting for Actionscript 2.0 in Adobe Flash CS3 or newer, check this page for more info.

Also make sure you have SQLAlchemy >= 0.4 installed.

Download

Grab the example from SVN with:

svn export http://svn.pyamf.org/pyamf/trunk/doc/tutorials/examples/actionscript/recordset recordset-example
cd recordset-example/python

Alternatively, if you just want to have a look, you can browse the example online.

Database

For this example the records are stored in a SQLite database. To generate the database file run:

python init.py

You should see something like:

Creating database...
Creating tables...
Successfully set up.

This created a file called temp.db in the folder where you executed the command.

Note: When you change the database schema in db.py make sure to delete the database file and run init.py again.

Gateway

The remoting gateway for the Adobe Flash Player and Python AMF clients starts on http://localhost:8000 when you launch the development server:

python gateway.py

You should see something like:

Started RecordSet example server on http://localhost:8000

Note: When you decide not to use the default host or port you will need to change the Actionscript and recompile the SWF as well.

Options

When you run python gateway.py –help it will display the various options available for this example server:

Usage: gateway.py [options]

Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  port number [default: 8000]
  --host=HOST           host address [default: localhost]

Clients

Flash Player

You can simply open the SWF file and it will connect to http://localhost:8000.

../../_images/recordset.jpg

Python

The Python AMF client can be started by running the following from the python folder:

python client.py

You should see something like this for the client:

2009-12-27 01:58:13,300 DEBUG [root] Connecting to http://localhost:8000
2009-12-27 01:58:13,300 DEBUG [root] Referer: None
2009-12-27 01:58:13,301 DEBUG [root] User-Agent: PyAMF/0.5.1
2009-12-27 01:58:13,301 DEBUG [root] Adding request service.getLanguages()
2009-12-27 01:58:13,301 DEBUG [root] Executing single request: /1
2009-12-27 01:58:13,301 DEBUG [root] AMF version: 0
2009-12-27 01:58:13,302 DEBUG [root] Sending POST request to
2009-12-27 01:58:13,307 DEBUG [root] Waiting for response...
2009-12-27 01:58:13,311 DEBUG [root] Got response status: 200
2009-12-27 01:58:13,311 DEBUG [root] Content-Type: application/x-amf
2009-12-27 01:58:13,311 DEBUG [root] Content-Length: 325
2009-12-27 01:58:13,311 DEBUG [root] Server: PyAMF/0.5.1 CPython/2.6.4
2009-12-27 01:58:13,311 DEBUG [root] Read 325 bytes for the response
2009-12-27 01:58:13,312 DEBUG [root] Response: <Envelope amfVersion=0>
(u'/1', <Response status=/onResult><pyamf.amf0.RecordSet object at 0x10063cc50></Response>)
</Envelope>
2009-12-27 01:58:13,312 DEBUG [root] Removing request: /1
Result: <pyamf.amf0.RecordSet object at 0x10063cc50>

Options

When you run python client.py –help it will display the various options available for this example client:

Usage: client.py [options]

Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  port number [default: 8000]
  --host=HOST           host address [default: localhost]