Guestbook

Introduction

This example shows how to create a simple guestbook application using Twisted and the Flex SDK.

A live demo can be found on the PyAMF blog.

../../_images/guestbook-example.jpg

Download

Clone the PyAMF repository with:

git clone git://github.com/hydralabs/pyamf.git pyamf
cd doc/tutorials/examples/actionscript/guestbook

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

Database

Note: make sure you have Twisted, MySQL-Python and MySQL installed.

This example uses a MySQL setup with a database called ‘guestbook’. The schema file is included that you need to run on your database first. The database host/username/password settings can be found in the config file.

Gateway

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

twistd -noy guestbook.tac

You should see something like:

2008-04-12 15:12:14+0200 [-] Log opened.
2008-04-12 15:12:14+0200 [-] twistd 8.0.1+r23300 (/usr/local/bin/python2.5 2.5.2) starting up
2008-04-12 15:12:14+0200 [-] reactor class: <class 'twisted.internet.selectreactor.SelectReactor'>
2008-04-12 15:12:14+0200 [-] twisted.web.server.Site starting on 8080
2008-04-12 15:12:14+0200 [-] Starting factory <twisted.web.server.Site instance at 0x12efb48>

Clients

Flash Player

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

Python

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

python client.py

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]