{ "info": { "author": null, "author_email": null, "bugtrack_url": null, "classifiers": [], "description": "django-serverpush\n=================\n\nEasy to use server push solution, highly integrated with django.\n\nRequirements\n------------\n\n* Django\n* Tornadio2\n\nIntroduction\n------------\n\nFor any django view, you can define an update function by just naming it the\nsame as view function and appending \"_update\".\n\nLets say we have a view called hello that says hello to the user:\n\n def hello(request):\n return HttpResponse('Hey, %s!' % request.user.username)\n\nNow we can define hello_update that returns what types of updates should affect\nthis page, and how will it be serialized:\n\n* We can use default serializer and just define what fields we need:\n\n def hello_update(request):\n return [{'name':'username_change', 'model':User, 'params':{'pk':request.user.pk}, 'data':{'username':'object.username'}}]\n\n But then we have to write a special bit of JavaScript to handle this:\n\n $(document).bind('serverpush_username_change', function(event, data) {\n $('body').html('Hey, ' + data.username + '!');\n });\n\n* We can write a custom serializer:\n\n def hello_update(request):\n # 'data' parameter is optional, and it is directly passed to the serializer\n return [{'name':'reload', 'model':User, 'params':{'pk':request.user.pk}, 'serializer':hello_update_serializer}]\n\n def hello_update_serializer(request, user, data):\n return 'Hey, %s!' % user.username\n\n And now we can either have a special JS for every page, or we can generalize\n them a bit, and have just one or a few (name in the update function is name for\n the JavaScript event).\n\n $(document).bind('serverpush_reload', function(event, data) {\n $('body').html(data);\n });\n\n In this example I called it reload, because all it does is swapping the HTML.\n\n* Or we can just use hello view function for serializing:\n\n def hello_update(request):\n return [{'name':'reload', 'model':User, 'params':{'pk':request.user.pk}, 'serializer':'hello'}]\n\n And change hello header a bit:\n\n def hello(request, user=None, data=None):\n\n And have one general JavaScript for the whole site / updates like that\n (of course we can mix all three types of updates):\n\n $(document).bind('serverpush_reload', function(event, data) {\n $('body').html(data);\n });\n\nWhy django-serverpush?\n----------------------\n\nBecause it's super easy to use, and requires very little additional code to\ntransform a traditional django application.\n\nInstallation\n------------\n\n1. Install this package\n\n sudo python setup.py install\n\n2. Update settings.py\n\n Add \"serverpush\" to INSTALLED_APPS and\n \"serverpush.client.context_processor\" to TEMPLATE_CONTEXT_PROCESSORS.\n Also add the following constants:\n\n SERVERPUSH_PORT = 8013\n SERVERPUSH_NOTIFIER_PORT = 8014\n SERVERPUSH_GLOBALS = ()\n\n3. Add a timestamp div to your template (for history to work)\n\n
\n {{ generated_timestamp }}\n
\n\n4. Run it by calling ./manage.py runserverpush\n\nRunning Demo\n------------\n\n1. Create sqlite file\n\n ./manage.py syncdb\n\n2. Run django development server\n\n ./manage.py runserver\n\n3. Run serverpush server\n\n ./manage.py runserverpush\n\n4. Navigate to localhost:8000 in multiple browsers/windows/tabs and observe the counter\n\nBrowser support\n---------------\n\nIt's based on socket.io, so it should work in all major browsers.\nCurrently there are problems with opera (because it doesn't allow cross port\nXHR, and JSONP makes it \"load\"), but I'm working on resolving them. Simple\nsolution would be to proxy XHR.\n", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": null, "keywords": null, "license": null, "maintainer": null, "maintainer_email": null, "name": "django-serverpush", "package_url": "https://pypi.org/project/django-serverpush/", "platform": null, "project_url": "https://pypi.org/project/django-serverpush/", "project_urls": null, "release_url": "https://pypi.org/project/django-serverpush/2.1.0/", "requires_dist": null, "requires_python": null, "summary": null, "version": "2.1.0" }, "last_serial": 790577, "releases": { "2.1.0": [ { "comment_text": "", "digests": { "md5": "fed596f7eb7cf2967c026b0f9bbb71e0", "sha256": "fbc8c6dbd3ef04e2bf3b0a72364f207c1f21fe7f53270bb04e22b37fe31fbe31" }, "downloads": -1, "filename": "django-serverpush.zip", "has_sig": false, "md5_digest": "fed596f7eb7cf2967c026b0f9bbb71e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11144, "upload_time": "2012-03-21T18:09:04", "url": "https://files.pythonhosted.org/packages/6b/ca/c7ebf0b64040c06ac7e2f3231ade227b641aa670a1d7df27c79ae01b4535/django-serverpush.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fed596f7eb7cf2967c026b0f9bbb71e0", "sha256": "fbc8c6dbd3ef04e2bf3b0a72364f207c1f21fe7f53270bb04e22b37fe31fbe31" }, "downloads": -1, "filename": "django-serverpush.zip", "has_sig": false, "md5_digest": "fed596f7eb7cf2967c026b0f9bbb71e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11144, "upload_time": "2012-03-21T18:09:04", "url": "https://files.pythonhosted.org/packages/6b/ca/c7ebf0b64040c06ac7e2f3231ade227b641aa670a1d7df27c79ae01b4535/django-serverpush.zip" } ] }