{ "info": { "author": "Alessandro Molina", "author_email": "alessandro.molina@axant.it", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "About tgext.socketio\n-------------------------\n\n.. image:: https://travis-ci.org/amol-/tgext.socketio.png\n :target: https://travis-ci.org/amol-/tgext.socketio\n\n.. image:: https://coveralls.io/repos/amol-/tgext.socketio/badge.png\n :target: https://coveralls.io/r/amol-/tgext.socketio\n\n.. image:: https://img.shields.io/pypi/pyversions/tgext.socketio.svg\n :target: https://pypi.python.org/pypi/tgext.socketio\n\ntgext.socketio provides an easy way to implement SocketIO in TurboGears2.\nSocketIO support is provided by gevent-socketio and specific SocketIO server\nbased on gevent is provided.\n\nInstalling\n-------------------------------\n\ntgextsocketio can be installed from pypi::\n\n pip install tgext.socketio\n\nRunning\n------------------------------\n\nSocketIO support requires a custom GEvent based HTTP server to work\ncorrectly, remember to edit your ``development.ini`` and add::\n\n # SOCKETIO doesn't work with debug mode\n debug = false\n\n [server:main]\n use = egg:tgext.socketio#socketio\n socketio_resource = socketio\n\n host = 127.0.0.1\n port = 8080\n\n``tgext.socketio#socketio`` is the server provided by tgext.socketio\nto correctly support SocketIO, while ``socketio_resource`` is the\npath of your ``SocketIOController`` class.\n\nBy default ``socketio`` is used so you can mount a ``SocketIOController``\nsubclass under the ``RootController`` or you can mount it in any other location\nand change your ``socketio_resource`` option.\n\nUsing SocketIOController\n----------------------------------\n\n``SocketIOController`` works like any other TurboGears controller but supports\nserving ``SocketIOTGNamespace`` as sub controllers. ``SocketIOController`` can\nalso behave like any other TG Controller and provide normal web pages.\n\n``SocketIOTGNamespace`` are subclasses of ``socketio.namespace.Basenamespace`` with\nadditional TurboGears features like ``@validate`` and ``@require`` support.\nPlease keep in mind that ``SocketIOTGNamespace`` requires at least TurboGears **2.3.1**,\nif you want to use a previous TurboGears version you can still use ``SocketIOController``\nwith plain ``socketio.namespace.Basenamespace`` classes.\n\nUsage Example\n=====================\n\nThe following is a very simple example that handles two type of events\n``ping`` and ``fireball`` and response on real time to those::\n\n from tgext.socketio import SocketIOTGNamespace, SocketIOController\n\n class PingPong(SocketIOTGNamespace):\n def on_ping(self, attack):\n if attack['type'] == 'fireball':\n for i in range(10):\n self.emit('pong',{'sound':'bang!'})\n else:\n self.emit('pong',{'sound':'pong'})\n\n\n class SocketIO(SocketIOController):\n pingpong = PingPong\n\n @expose()\n def page(self, **kw):\n return '''\n \n \n
\n Ping\n Fireball\n Auto\n Error\n
\n
\n \n \n \n \n \n '''\n\n class RootController(BaseController):\n socketio = SocketIO()\n\nKeep in mind that the ``SocketIOController`` must be mounted in the same location\nspecified by ``socketio_resource`` property in your configuration file.\n\nUsing Validators and Requirements\n=====================================\n\n``SocketIOTGNamespace`` also supports using ``@validate`` and\n``@require`` TurboGears decorators.\n\nThe same example can be changed to provide validation and\npermission checks with a few lines of code::\n\n from tg import validate, require, predicates\n from tg.validation import TGValidationError\n import random\n\n class NoFireBallValidator(object):\n def to_python(self, value, *args, **kw):\n type_ = value['type']\n if type_ == 'auto':\n return {'type': random.choice(['ping', 'fireball'])}\n elif type_ == 'error':\n raise TGValidationError('Got an error!')\n\n return value\n\n\n class PingPong(SocketIOTGNamespace):\n @require(predicates.not_anonymous())\n @validate({'attack': NoFireBallValidator()})\n def on_ping(self, attack):\n if attack['type'] == 'fireball':\n for i in range(10):\n self.emit('pong',{'sound':'bang!'})\n else:\n self.emit('pong',{'sound':'pong'})\n\n\nPubSub Support\n---------------------------------------\n\n``tgext.socketio`` has builtin support for PubSub paradigm based\non ``anypubsub`` library. If you want to use PubSub you should install\nanypubsub through ``pip install anypubsub`` or add it to your project\ndependencies.\n\nPubSub support works by subclassing from ``tgext.socketio.pubsub.PubSubTGNamespace``\nthis special namespace permits clients to subscribe to channels using\n``socket.emit('subscribe', 'channel_name')`` from the javascript interface.\n\nWhenever an user subscribes to a channel, the PubSubTGNamespace subclass will receive\na call for ``subscribe_channelname`` method, which can return if the user is permitted\nto subscribe to the given channel or not (``@require`` decorator can be used).\nThe ``subscribe_channelname`` method can also return a different channel name if you want\nto specify a subchannel.\n\nFor each message published on the subscribed channel PubSubTGNamespace will emit a\n``pubblication`` event, which can be trapped by the socket.io client to perform required\nactions.\n\nPublishing a message will be possible through ``PubSubTGNamespace.publish``.\n\nYou can see a simple example providing a real time chat implemented on redis backend\nin `examples/chat.py `_\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/amol-/tgext.socketio", "keywords": "turbogears2.extension", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "tgext.socketio", "package_url": "https://pypi.org/project/tgext.socketio/", "platform": "", "project_url": "https://pypi.org/project/tgext.socketio/", "project_urls": { "Homepage": "http://github.com/amol-/tgext.socketio" }, "release_url": "https://pypi.org/project/tgext.socketio/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "SocketIO support for TurboGears through gevent-socketio", "version": "0.0.3" }, "last_serial": 3124020, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "8b169ad58ba5aa575e0b1d3af84361fa", "sha256": "1206467c360787af0867a1c0ed568d210a45a6466db9db179d962c859170d337" }, "downloads": -1, "filename": "tgext.socketio-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8b169ad58ba5aa575e0b1d3af84361fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7554, "upload_time": "2014-07-06T14:49:39", "url": "https://files.pythonhosted.org/packages/82/f1/73d3a686984083dd9847c6e1cf346dae8b02cd0187348e3c2554c23420ff/tgext.socketio-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "6a2a64cc1719163b32328a117e2ab6db", "sha256": "a345f4c3971ab19b2929645b2e15a22293743bf6536a31de50b4ece495f477bb" }, "downloads": -1, "filename": "tgext.socketio-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6a2a64cc1719163b32328a117e2ab6db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7639, "upload_time": "2017-08-22T19:39:07", "url": "https://files.pythonhosted.org/packages/ac/1c/071593a5c151ead6b8fbcb25ad61f5c1a0b66175510bd32b3c5f2ec72d45/tgext.socketio-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "acc50ef775aaf8eb79742142cb469eb1", "sha256": "488c344a20610944fc58cdb526e2bf3b3cd837146d68393cfbbbb4a77a6b47ed" }, "downloads": -1, "filename": "tgext.socketio-0.0.3.tar.gz", "has_sig": false, "md5_digest": "acc50ef775aaf8eb79742142cb469eb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7762, "upload_time": "2017-08-25T20:48:20", "url": "https://files.pythonhosted.org/packages/36/d6/a45823cad31c259ba1ab90e722c54cf12eef21e9ef9eb5793b1378d0885c/tgext.socketio-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "acc50ef775aaf8eb79742142cb469eb1", "sha256": "488c344a20610944fc58cdb526e2bf3b3cd837146d68393cfbbbb4a77a6b47ed" }, "downloads": -1, "filename": "tgext.socketio-0.0.3.tar.gz", "has_sig": false, "md5_digest": "acc50ef775aaf8eb79742142cb469eb1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7762, "upload_time": "2017-08-25T20:48:20", "url": "https://files.pythonhosted.org/packages/36/d6/a45823cad31c259ba1ab90e722c54cf12eef21e9ef9eb5793b1378d0885c/tgext.socketio-0.0.3.tar.gz" } ] }