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 WSGI Application
---------------- ----------------
:mod:`wsme.wsgi` -- WSGI adapter The :func:`wsme.WSRoot.wsgiapp` function of WSRoot returns a wsgi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ application.
.. module:: wsme.wsgi
.. function:: adapt
Returns a wsgi application that serve a :class:`wsme.controller.WSRoot`.
Example Example
~~~~~~~ ~~~~~~~
.. code-block:: python .. code-block:: python
from wsme import * from wsme import WSRoot, expose
import wsme.wsgi
class MyRoot(WSRoot): class MyRoot(WSRoot):
@expose(unicode) @expose(unicode)
def helloworld(self): def helloworld(self):
return u"Hello World !" return u"Hello World !"
application = wsme.wsgi.adapt( root = MyRoot(protocols=['restjson'])
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 Pyramid
------- -------