Change the wsgi example to match the new way of obtaining a wsgi app from a WSRoot.

Add a bottle integration example
This commit is contained in:
Christophe de Vienne 2012-08-12 15:07:02 +02:00
parent 3223c648ed
commit 3b1168ef26

View File

@ -4,32 +4,44 @@ Integrating with a Framework
WSGI Application
----------------
:mod:`wsme.wsgi` -- WSGI adapter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. module:: wsme.wsgi
.. function:: adapt
Returns a wsgi application that serve a :class:`wsme.controller.WSRoot`.
The :func:`wsme.WSRoot.wsgiapp` function of WSRoot returns a wsgi
application.
Example
~~~~~~~
.. code-block:: python
from wsme import *
import wsme.wsgi
from wsme import WSRoot, expose
class MyRoot(WSRoot):
@expose(unicode)
def helloworld(self):
return u"Hello World !"
application = wsme.wsgi.adapt(
MyRoot(protocols=['restjson']))
root = MyRoot(protocols=['restjson'])
application = root.wsgiapp()
Bottle
------
.. code-block:: python
import bottle
import wsme
class MyRoot(wsme.WSRoot):
@wsme.expose(unicode)
def helloworld(self):
return u"Hello World !"
root = MyRoot(webpath='/ws', protocols=['restjson'])
bottle.mount('/ws', root.wsgiapp())
bottle.run()
Pyramid
-------