|
2 | 2 | Pylons Project
|
3 | 3 | ******************
|
4 | 4 |
|
| 5 | +.. image:: images/pylons-logo.png |
| 6 | + |
5 | 7 | .. topic:: Introduction
|
6 | 8 |
|
7 | 9 | The `Pylons Project`_ is a collection of web application framework
|
8 | 10 | technologies. This tutorial describes how to setup a bare bones
|
9 | 11 | application with a remoting gateway exposing a method.
|
10 | 12 |
|
11 |
| - **Note**: This tutorial provides examples for both Pyramid_ and the old |
12 |
| - `Pylons package`_ (versions 0.97-1.x). For new projects it is recommended |
| 13 | + **Note**: This tutorial provides examples for both Pyramid_ and the legacy |
| 14 | + `Pylons package`_ (versions 0.97-1.x). For new projects it is encouraged |
13 | 15 | to use the Pyramid package, see the `Pylons FAQ`_ for more information.
|
14 | 16 |
|
15 | 17 |
|
|
19 | 21 | Pyramid
|
20 | 22 | =======
|
21 | 23 |
|
22 |
| -The Pyramid_ package supports extensibility through add-ons. For this tutorial |
23 |
| -we need RPC support for AMF_ which is available in the `pyramid_rpc`_ add-on. |
| 24 | +Pyramid_ is a small, fast, down-to-earth Python web application development |
| 25 | +framework. It is developed as part of the `Pylons Project`_. |
24 | 26 |
|
25 |
| -Install_ the ``pyramid_rpc`` package: |
| 27 | +Example |
| 28 | +------- |
| 29 | + |
| 30 | +1. Create a new virtual environment using the virtualenv_ tool: |
26 | 31 |
|
27 | 32 | .. code-block:: bash
|
28 | 33 |
|
29 |
| - $ easy_install pyramid_rpc |
| 34 | + $ virtualenv --no-site-packages pyramid_amf_env |
30 | 35 |
|
31 | 36 |
|
32 |
| -Example |
33 |
| -------- |
| 37 | +2. The Pyramid_ package supports extensibility through add-ons. For this tutorial |
| 38 | + we need AMF support which is available in the `pyramid_rpc`_ add-on. |
| 39 | + |
| 40 | + Install the ``pyramid``, ``pyramid_rpc`` and ``pyamf`` packages: |
| 41 | + |
| 42 | + .. code-block:: bash |
| 43 | +
|
| 44 | + $ cd pyramid_amf_env |
| 45 | + $ bin/easy_install pyramid pyramid_rpc pyamf |
34 | 46 |
|
35 |
| -1. Create a new Python script called ``server.py`` with the following: |
| 47 | +
|
| 48 | + For more detailed instructions, refer to the Pyramid `installation documentation`_. |
| 49 | + |
| 50 | + |
| 51 | +3. Create a new Pyramid project (called ``pyamf_tutorial`` in this example): |
| 52 | + |
| 53 | + .. code-block:: bash |
| 54 | +
|
| 55 | + $ bin/paster create -t pyramid_starter pyamf_tutorial |
| 56 | +
|
| 57 | +
|
| 58 | +4. Install the project into the enviroment: |
| 59 | + |
| 60 | + .. code-block:: bash |
| 61 | +
|
| 62 | + $ cd pyamf_tutorial |
| 63 | + $ ../bin/python setup.py develop |
| 64 | +
|
| 65 | +
|
| 66 | +5. Replace the contents of ``pyamf_tutorial/views.py`` with the following: |
36 | 67 |
|
37 | 68 | .. literalinclude:: ../examples/gateways/pylons/pyramid_gateway.py
|
38 | 69 | :linenos:
|
39 | 70 |
|
40 | 71 | You can easily expose more functions by adding them to the ``services`` dictionary
|
41 |
| - given to ``PyramidGateway``. |
| 72 | + given to ``PyramidGateway``. Also see the `pyramid_rpc documentation`_. |
| 73 | + |
| 74 | + |
| 75 | +6. Add the view to the routing map, open ``pyamf_tutorial/__init__.py`` and look for the line: |
42 | 76 |
|
| 77 | + .. code-block:: python |
| 78 | +
|
| 79 | + config.add_static_view('static', 'pyamf_tutorial:static') |
| 80 | +
|
| 81 | + Just above that line, configure the route to the view you created earlier. |
43 | 82 |
|
44 |
| -2. Fire up the web server with: |
| 83 | + .. code-block:: python |
| 84 | + |
| 85 | + config.add_view('pyamf_tutorial.views.echoGateway', name='gateway') |
| 86 | +
|
| 87 | +
|
| 88 | +7. Fire up the web server with: |
45 | 89 |
|
46 | 90 | .. code-block:: bash
|
47 | 91 |
|
48 |
| - $ python server.py |
| 92 | + $ ../bin/paster serve development.ini |
49 | 93 |
|
50 | 94 | That should print something like:
|
51 | 95 |
|
52 | 96 | .. code-block:: bash
|
53 | 97 |
|
54 |
| - serving on 0.0.0.0:8080 view at http://127.0.0.1:8080 |
| 98 | + Starting server in PID 16601. |
| 99 | + serving on 0.0.0.0:6543 view at http://127.0.0.1:6543 |
55 | 100 |
|
56 | 101 |
|
57 |
| -3. To test the gateway you can use a Python AMF client like this: |
| 102 | +8. To test the gateway you can use a Python AMF client like this: |
58 | 103 |
|
59 | 104 | .. literalinclude:: ../examples/gateways/pylons/pyramid_client.py
|
60 | 105 | :linenos:
|
61 | 106 |
|
62 | 107 |
|
63 |
| -Pylons |
64 |
| -====== |
| 108 | + |
| 109 | +Pylons (0.97-1.x) |
| 110 | +================= |
| 111 | + |
| 112 | +This section of the tutorial covers the legacy `Pylons package`_. |
| 113 | + |
| 114 | +Example |
| 115 | +------- |
65 | 116 |
|
66 | 117 | 1. Create a new Pylons project with:
|
67 | 118 |
|
@@ -141,5 +192,6 @@ Pylons
|
141 | 192 | .. _Pylons package: http://docs.pylonsproject.org/docs/pylons.html
|
142 | 193 | .. _pyramid_rpc: http://docs.pylonsproject.org/projects/pyramid_rpc/dev/
|
143 | 194 | .. _Pylons FAQ: http://docs.pylonsproject.org/faq/pylonsproject.html
|
144 |
| -.. _AMF: http://docs.pylonsproject.org/projects/pyramid_rpc/dev/amf.html |
145 |
| -.. _Install: http://docs.pylonsproject.org/projects/pyramid_rpc/dev/#installation |
| 195 | +.. _pyramid_rpc documentation: http://docs.pylonsproject.org/projects/pyramid_rpc/dev/amf.html |
| 196 | +.. _virtualenv: http://pypi.python.org/pypi/virtualenv |
| 197 | +.. _installation documentation: http://docs.pylonsproject.org/projects/pyramid/1.1/narr/install.html#installing-chapter |
0 commit comments