{ "info": { "author": "Simon Harrison", "author_email": "noisyboiler@googlemail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": ".. -*- mode: rst -*-\n\n|Travis|_ |Python27|_ |Python34|_ |Python35|_ |Python36|_ \n\n.. |Travis| image:: https://travis-ci.org/noisyboiler/flask-wamp.svg?branch=master\n.. _Travis: https://travis-ci.org/noisyboiler/wampy\n\n.. |Python27| image:: https://img.shields.io/badge/python-2.7-blue.svg\n.. _Python27: https://pypi.python.org/pypi/wampy/\n\n.. |Python34| image:: https://img.shields.io/badge/python-3.4-blue.svg\n.. _Python34: https://pypi.python.org/pypi/wampy/\n\n.. |Python35| image:: https://img.shields.io/badge/python-3.5-blue.svg\n.. _Python35: https://pypi.python.org/pypi/wampy/\n\n.. |Python36| image:: https://img.shields.io/badge/python-3.6-blue.svg\n.. _Python36: https://pypi.python.org/pypi/wampy/\n\n\nFlask-WAMP\n~~~~~~~~~~\n\nFlask apps with `WAMP`_ messaging.\n\nFor a background as to what WAMP is, please see `here`_.\n\nRemember, The Web Application Messaging Protocl is not *just* for the Web. So, if you would like your Flask app to be a WAMP component in a larger architecture... then you can! **flask-wamp** gives you two options:\n\n1. rRPC or PubSub messaging between Flask Apps, supporting a micro-service architecture for the backend\n2. rRPC or PubSub messaging between your Browser and Flask Apps, supporting async, concurrent calls and real-time updates for the frontend users\n\nFor both you'll need a WAMP Router/Broker Peer, and for that I recommend `Crossbar.io`_.\n\nUse Cases\n---------\n\n- Realtime updates between Browsers (I suggest `wampy.js`_) and Flask Apps\n- Upgrading the power of existing Flask micro-services\n\nWhy Not Just WebSockets?\n------------------------\n\nWebSockets are of course a sound implementation for real-time client-server communication. You'll need some Flask Middleware for this, such as `Flask-SocketIO`_, or `flask-sockets`_. With WAMP, you do not.\n\nYou might then struggle to find a mature WebSocket RPC between your components, and even if you do, each component will need to know the other exists and exacrtly the host, port and path to find it on - with WAMP you do not.\n\nWith WAMP you also have consistency in technology between front end and back, and inter-communication between backend components.\n\nThe only real hurdle you'll face is getting Crossbar.io up and running with sensible configuration, but there are great support `docs`_ for this and the basic usecase for demos and early development is trivial. And this Router/Broker Peer is a compelling reason to choose WAMP as it has sophisticaed messaging patterns and advanced features such as authN/Z and meta events. Regarding the client Peers, `wampy.js`_ and flask-wamp make this incredibly straight forward.\n\nAnother reason you might want to consider flask-wamp for your Flask Messaging is that under the hood it uses *wampy*, and wampy can be configured to use either `eventlet`_ or `Gevent`_, so if your architecture is already tied to one of these, flask-wamp can use the async networking solution of your choice.\n\nWAMP in general has desirable features that you'd get out-of-the-box, such as load balancing and a variety of auth patterns.\n\nHow It Works\n------------\n\nThis is a standard Flask Extension.\n\nUnder the hood you have a single `wampy`_ client instance with a WAMP WebSocket connection to Crossbar. So for every instance of your Flask App you have, you also have a single instance of wampy. You must wrap your Flask App in the flask-wamp App to achieve this, providing the Router host and Realm name. This should come from your Flask Config object - see `test_flask_wamp.py`_ for an example.\n\nThen, much like with `nameko-wamp`_, you can declare a Flask endpoint/view to fulfill the WAMP Callee or Subscriber Role. This is doesn't stop you also routing HTTP requests to these views - bargain!\n\nOnce you've done this it can be communicated with over the WAMP protocol by any other WAMP Caller or Publisher component, whether this is another Flask App or a Browser, and assuming they are all attached to the same Realm. Declarations are done with *decorators*. What these \"views\" then do under the decoration is entirelly up to you.\n\nFor a Flask Peer to fulfill a Caller or Publisher Role you need a handle on that **wampy** instance and the API it provides. Again, just like `nameko-wamp`_, we use Dependency Injection so all your views have access to wampy via the **g** object. For example,\n\n.. code-block:: python\n\n from flask import g\n\n def my_view_function():\n wampy = g.wampy\n wampy.rpc.some_remote_procedure(*args, **kwargs)\n wampy.publish(topic=\"some topic\", message=\"this is fun!\")\n\n # maybe do other stuff and return something\n\nEvery view will have access to wampy, whether it is a decorated view or not. Wampy is already connected to Crossbar so you do *not* need to use it as a context manager as the `wampy`_ docs suggest. See `ReadTheDocs`_ for more on wampy's API.\n\nRunning the tests\n~~~~~~~~~~~~~~~~~\n\nThe test runner uses the Crossbar test fixture provided by wampy.\n\n::\n\n $ pip install --editable .[dev]\n $ py.test ./test -v\n\n\nor, more simply\n\n::\n\n\t$ make tests\n\n\n.. _Crossbar.io: http://crossbar.io/docs/Quick-Start/\n.. _docs: https://crossbar.io/docs/\n.. _nameko-wamp: https://github.com/noisyboiler/nameko-wamp\n.. _Flask-SocketIO: https://github.com/miguelgrinberg/Flask-SocketIO/\n.. _flask-sockets: https://github.com/heroku-python/flask-sockets\n.. _wampy.js: https://github.com/KSDaemon/wampy.js/\n.. _WAMP Protocol: http://wamp-proto.org/\n.. _WAMP: http://wamp-proto.org/\n.. _here: https://medium.com/@noisyboiler/the-web-application-messaging-protocol-d8efe95aeb67\n.. _ReadTheDocs: http://wampy.readthedocs.io/en/latest/\n.. _Gevent: http://www.gevent.org/\n.. _eventlet: http://eventlet.net/\n.. _wampy: https://github.com/noisyboiler/wampy\n.. _test_flask_wamp.py: https://github.com/noisyboiler/flask-wamp/blob/master/tests/test_flask_wamp.py\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/noisyboiler/flask-wamp", "keywords": "WAMP RPC Flask", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "Flask-WAMP", "package_url": "https://pypi.org/project/Flask-WAMP/", "platform": "", "project_url": "https://pypi.org/project/Flask-WAMP/", "project_urls": { "Homepage": "https://github.com/noisyboiler/flask-wamp" }, "release_url": "https://pypi.org/project/Flask-WAMP/0.1.0/", "requires_dist": [ "Flask (==1.0.2)", "wampy (==0.9.20)", "crossbar (==0.15.0) ; extra == 'dev'", "autobahn (==0.17.2) ; extra == 'dev'", "Twisted (==17.9.0) ; extra == 'dev'", "pytest (==4.0.2) ; extra == 'dev'", "mock (==1.3.0) ; extra == 'dev'", "pytest-capturelog (==0.7) ; extra == 'dev'", "colorlog ; extra == 'dev'", "flake8 (==3.5.0) ; extra == 'dev'", "gevent-websocket (==0.10.1) ; extra == 'dev'", "coverage (>=3.7.1) ; extra == 'dev'" ], "requires_python": "", "summary": "WAMP RPC and Pub/Sub for Flask", "version": "0.1.0" }, "last_serial": 4646591, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "f2a0bd9afc21c0f94190f616a963f75d", "sha256": "09d1da1eaf06c4a2de0b545175286bd78457e63380c9b57536f469cc71c2a7a5" }, "downloads": -1, "filename": "Flask_WAMP-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f2a0bd9afc21c0f94190f616a963f75d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4753, "upload_time": "2018-12-30T17:02:40", "url": "https://files.pythonhosted.org/packages/ef/f7/60a53dc91b58a404997a5ef7fa600af13091209b5e237ee1dd11063f1deb/Flask_WAMP-0.1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f2a0bd9afc21c0f94190f616a963f75d", "sha256": "09d1da1eaf06c4a2de0b545175286bd78457e63380c9b57536f469cc71c2a7a5" }, "downloads": -1, "filename": "Flask_WAMP-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f2a0bd9afc21c0f94190f616a963f75d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4753, "upload_time": "2018-12-30T17:02:40", "url": "https://files.pythonhosted.org/packages/ef/f7/60a53dc91b58a404997a5ef7fa600af13091209b5e237ee1dd11063f1deb/Flask_WAMP-0.1.0-py2.py3-none-any.whl" } ] }