Add a pyramid integration example
This commit is contained in:
parent
6dd2e67a2d
commit
bbe98838ff
@ -29,6 +29,36 @@ Example
|
|||||||
application = wsme.wsgi.adapt(
|
application = wsme.wsgi.adapt(
|
||||||
MyRoot(protocols=['restjson']))
|
MyRoot(protocols=['restjson']))
|
||||||
|
|
||||||
|
|
||||||
|
Pyramid
|
||||||
|
-------
|
||||||
|
|
||||||
|
The WSRoot._handle_request method is a valid pyramid view:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from paste.httpserver import serve
|
||||||
|
from pyramid.config import Configurator
|
||||||
|
|
||||||
|
from wsme import *
|
||||||
|
|
||||||
|
class WSController(WSRoot):
|
||||||
|
@expose(int)
|
||||||
|
@validate(int, int)
|
||||||
|
def multiply(self, a, b):
|
||||||
|
return a * b
|
||||||
|
|
||||||
|
myroot = WSRoot()
|
||||||
|
myroot.addprotocol('restjson')
|
||||||
|
myroot.addprotocol('extdirect')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
config = Configurator()
|
||||||
|
config.add_route('ws', '')
|
||||||
|
config.add_view(wsroot._handle_request, route_name='ws')
|
||||||
|
app = config.make_wsgi_app()
|
||||||
|
serve(app, host='0.0.0.0')
|
||||||
|
|
||||||
Turbogears 1.x
|
Turbogears 1.x
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user