2011-10-22 16:30:01 +02:00
|
|
|
Web Services Made Easy
|
|
|
|
======================
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
------------
|
|
|
|
|
2013-01-30 00:30:04 +01:00
|
|
|
Web Service Made Easy (WSME) simplify the writing of REST web services
|
|
|
|
by providing simple yet powerful typing which removes the need to directly
|
|
|
|
manipulate the request and the response objects.
|
2012-12-11 09:56:58 +01:00
|
|
|
|
2013-01-30 00:30:04 +01:00
|
|
|
WSME can work standalone or on top of your favorite python web
|
|
|
|
(micro)framework, so you can use both your prefered way of routing your REST
|
|
|
|
requests and most of the features of WSME that rely on the typing system like:
|
|
|
|
|
|
|
|
- Alternate protocols, including ones supporting batch-calls
|
|
|
|
- Easy documentation through a Sphinx_ extension
|
|
|
|
|
|
|
|
WSME is originally a rewrite of TGWebServices
|
2011-10-22 15:59:24 +02:00
|
|
|
with focus on extensibility, framework-independance and better type handling.
|
2011-10-02 22:05:41 +02:00
|
|
|
|
2012-04-23 11:15:42 +02:00
|
|
|
How Easy ?
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
2013-01-30 00:30:04 +01:00
|
|
|
Here is a standalone wsgi example::
|
2012-04-23 11:15:42 +02:00
|
|
|
|
2013-10-08 15:51:41 +02:00
|
|
|
from wsme import WSRoot, expose
|
2012-04-23 11:15:42 +02:00
|
|
|
|
|
|
|
class MyService(WSRoot):
|
2013-02-08 21:42:39 +01:00
|
|
|
@expose(unicode, unicode) # First parameter is the return type,
|
|
|
|
# then the function argument types
|
2012-04-23 11:15:42 +02:00
|
|
|
def hello(self, who=u'World'):
|
|
|
|
return u"Hello {0} !".format(who)
|
|
|
|
|
2013-01-30 00:30:04 +01:00
|
|
|
ws = MyService(protocols=['restjson', 'restxml', 'soap'])
|
|
|
|
application = ws.wsgiapp()
|
2012-04-23 11:15:42 +02:00
|
|
|
|
|
|
|
With this published at the ``/ws`` path of your application, you can access
|
|
|
|
your hello function in various protocols:
|
|
|
|
|
2012-04-23 11:28:40 +02:00
|
|
|
.. list-table::
|
|
|
|
:header-rows: 1
|
2012-04-23 11:15:42 +02:00
|
|
|
|
2012-04-23 11:28:40 +02:00
|
|
|
* - URL
|
|
|
|
- Returns
|
|
|
|
|
|
|
|
* - ``http://<server>/ws/hello.json?who=you``
|
|
|
|
- ``"Hello you !"``
|
2012-04-23 11:15:42 +02:00
|
|
|
|
2012-04-23 11:28:40 +02:00
|
|
|
* - ``http://<server>/ws/hello.xml``
|
|
|
|
- ``<result>Hello World !</result>``
|
2012-04-23 11:15:42 +02:00
|
|
|
|
2012-04-23 11:28:40 +02:00
|
|
|
* - ``http://<server>/ws/api.wsdl``
|
|
|
|
- A WSDL description for any SOAP client.
|
2012-04-23 11:15:42 +02:00
|
|
|
|
|
|
|
|
2011-10-22 15:59:24 +02:00
|
|
|
Main features
|
|
|
|
~~~~~~~~~~~~~
|
2011-10-02 22:05:41 +02:00
|
|
|
|
2011-10-22 15:59:24 +02:00
|
|
|
- Very simple API.
|
2012-06-29 22:09:40 +02:00
|
|
|
- Supports user-defined simple and complex types.
|
2011-10-29 00:15:02 +02:00
|
|
|
- Multi-protocol : REST+Json, REST+XML, SOAP, ExtDirect and more to come.
|
2011-10-02 22:05:41 +02:00
|
|
|
- Extensible : easy to add more protocols or more base types.
|
2011-10-22 15:59:24 +02:00
|
|
|
- Framework independance : adapters are provided to easily integrate
|
2012-04-23 11:34:18 +02:00
|
|
|
your API in any web framework, for example a wsgi container,
|
2013-03-28 11:38:20 +01:00
|
|
|
Pecan_, TurboGears_, Flask_, cornice_...
|
2013-01-25 23:43:59 +01:00
|
|
|
- Very few runtime dependencies: webob, simplegeneric. Optionnaly lxml and
|
|
|
|
simplejson if you need better performances.
|
2012-04-05 10:46:32 +02:00
|
|
|
- Integration in `Sphinx`_ for making clean documentation with
|
2013-01-18 11:05:05 +01:00
|
|
|
``wsmeext.sphinxext``.
|
2011-10-22 15:59:24 +02:00
|
|
|
|
2012-12-11 09:56:58 +01:00
|
|
|
.. _Pecan: http://pecanpy.org/
|
|
|
|
.. _TurboGears: http://www.turbogears.org/
|
2013-03-28 11:38:20 +01:00
|
|
|
.. _Flask: http://flask.pocoo.org/
|
2012-12-11 09:56:58 +01:00
|
|
|
.. _cornice: http://pypi.python.org/pypi/cornice
|
|
|
|
|
2011-10-22 15:59:24 +02:00
|
|
|
Install
|
|
|
|
~~~~~~~
|
|
|
|
|
2013-04-18 19:33:54 +02:00
|
|
|
::
|
|
|
|
|
|
|
|
pip install WSME
|
|
|
|
|
|
|
|
or, if you do not have pip on your system or virtualenv
|
|
|
|
|
2011-10-29 00:15:02 +02:00
|
|
|
::
|
|
|
|
|
2012-04-23 11:29:33 +02:00
|
|
|
easy_install WSME
|
2011-10-22 15:59:24 +02:00
|
|
|
|
2012-04-23 11:48:15 +02:00
|
|
|
Changes
|
|
|
|
~~~~~~~
|
|
|
|
|
|
|
|
- Read the `Changelog`_
|
|
|
|
|
2011-10-22 15:59:24 +02:00
|
|
|
Getting Help
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
2011-10-22 16:36:31 +02:00
|
|
|
- Read the `WSME Documentation`_.
|
2012-04-23 23:23:12 +02:00
|
|
|
- Questions about WSME should go to the `python-wsme mailinglist`_.
|
2011-10-22 15:59:24 +02:00
|
|
|
|
|
|
|
Contribute
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
:Report issues: `WSME issue tracker`_
|
2013-08-20 14:56:12 -04:00
|
|
|
:Source code: git clone https://github.com/stackforge/wsme/
|
2013-08-20 23:24:43 +02:00
|
|
|
:Gerrit: https://review.openstack.org/#/q/project:stackforge/wsme,n,z/
|
2011-10-22 16:32:11 +02:00
|
|
|
|
2012-04-23 11:48:15 +02:00
|
|
|
.. _Changelog: http://packages.python.org/WSME/changes.html
|
2011-10-22 16:32:11 +02:00
|
|
|
.. _python-wsme mailinglist: http://groups.google.com/group/python-wsme
|
2011-10-22 16:36:31 +02:00
|
|
|
.. _WSME Documentation: http://packages.python.org/WSME/
|
2013-08-20 14:56:12 -04:00
|
|
|
.. _WSME issue tracker: https://bugs.launchpad.net/wsme/+bugs
|
2012-04-05 10:46:32 +02:00
|
|
|
.. _Sphinx: http://sphinx.pocoo.org/
|