1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
****************************
Interactive Python Shell
****************************
.. topic:: Introduction
This document describes how to setup the interactive, stateful Flex
shell that runs Python code on the server using the Flex_ SDK,
:doc:`Google App Engine<../gateways/appengine>` and
:doc:`Django <../gateways/django>`.
.. contents::
We recommend you **don't** run this example on a production server because
it exposes major security risks. This example is for educational purposes ;)
A live demo can be found on the PyAMF `Google App Engine example page`_.
Download
========
Clone the PyAMF repository with:
.. code-block:: bash
git clone git://github.com/hydralabs/pyamf.git pyamf
cd doc/tutorials/examples/actionscript/shell
Alternatively, if you just want to have a look, you can browse_ the example online.
Setup
=====
**Note**: make sure you have Django_ >= 1.0 installed.
Database
--------
This example uses SQLite_ to provide session support. First initialise the database by running:
.. code-block:: bash
python manage.py syncdb
Should output the following:
.. code-block:: bash
Creating table django_content_type
Creating table django_session
Gateway
=======
The remoting gateway for the Adobe Flash Player and Python AMF clients is available on
http://localhost:8000/gateway/shell/ when you launch the `development server`_:
.. code-block:: bash
python manage.py runserver
You should see something like:
.. code-block:: bash
Validating models...
0 errors found
Django version 1.1.1, using settings 'python.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Client
======
Flash Player
------------
You can simply open the `SWF file`_ and it will connect to http://localhost:8000.
.. image:: images/shellexample.png
Python
------
The Python AMF client can be started by running the following from the `python`
folder:
.. code-block:: bash
python client.py
You should see something like this for the client:
.. code-block:: python
Connecting to http://localhost:8000/gateway/shell/
Welcome to the PyAMF 0.5.1 Shell Demo!
Python 2.6.4 (r264:75706, Dec 22 2009, 21:55:52)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
You can now use the interpreter as you normally would:
.. code-block:: python
>>> import sys
>>> sys.version
'2.6.4 (r264:75706, Dec 22 2009, 21:55:52) \n[GCC 4.2.1 (Apple Inc. build 5646)]'
Options
_______
When you run `python client.py --help` it will display the various options available
for this example client:
.. code-block:: bash
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]
.. _Flex: http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK
.. _Django: http://www.djangoproject.com
.. _Google App Engine example page: http://pyamf.appspot.com/shell
.. _browse: http://github.com/hydralabs/pyamf/tree/master/doc/tutorials/examples/actionscript/shell
.. _development server: http://github.com/hydralabs/pyamf/tree/master/doc/tutorials/examples/actionscript/shell/python/manage.py
.. _SQLite: http://sqlite.org
.. _SWF file: http://github.com/hydralabs/pyamf/tree/master/doc/tutorials/examples/actionscript/shell/flex/deploy/shell.swf
|