pyramid_sockjs
pyramid_sockjs is a gevent-based SockJS integration for Pyramid. SockJS interface is implemented as a pyramid route. pyramid_sockjs runs inside a WSGI application rather than WSGI server. This means all of your previous WSGI/Pyramid experience will be relevant. Its possible to create any number of different sockjs routes, ie /__sockjs__/* or /mycustom-sockjs/*. You can provide different session implementation and management for each sockjs route.
Gevent based server is required for pyramid_sockjs. For example gunicorn with gevent worker. pyramid_sockjs provides simple gevent based paster server runner:
[server:main] use = egg:pyramid_sockjs#server host = 0.0.0.0 port = 8080
Example of sockjs route:
def main(global_settings, **settings):
config = Configurator(settings=settings)
config.add_sockjs_route(prefix='/__sockjs__')
return config.make_wsgi_app()
Client side code:
<script src="http://cdn.sockjs.org/sockjs-0.3.4.min.js"></script>
<script>
var sock = new SockJS('http://localhost:8080/__sockjs__');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(obj) {
console.log(obj);
};
sock.onclose = function() {
console.log('close');
};
</script>
Installation
Install virtualenv:
$ wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py $ python2.7 ./virtualenv.py --no-site-packages sockjs
Install gevent 1.0rc2 (non-Windows):
$ ./sockjs/bin/pip install https://github.com/downloads/SiteSupport/gevent/gevent-1.0rc2.tar.gz
Install gevent 1.0rc1 (Windows, 32bit Python 2.7):
$ ./sockjs/Scripts/easy_install https://github.com/downloads/SiteSupport/gevent/gevent-1.0rc2.win32-py2.7.exe
Clone pyramid_sockjs from github and then install:
$ git clone https://github.com/fafhrd91/pyramid_sockjs.git $ cd pyramid_sockjs $ ../sockjs/bin/python setup.py develop
To run chat example use following command:
$ ./sockjs/bin/python ./pyramid_sockjs/examples/chat.py
Supported transports
iframe-eventsource (EventSource used from an iframe via postMessage)
iframe-htmlfile (HtmlFile used from an iframe via postMessage.)
Limitations
Pyramid sockjs does not support multple websocket session with same session id.
gevent does not support Python 3
Pyramid sockjs can’t detect client disconnection on heroku.
Requirements
Examples
You can find several examples in the pyramid_sockjs repository at github.
https://github.com/fafhrd91/pyramid_sockjs/tree/master/examples
License
pyramid_sockjs is offered under the MIT license.
CHANGES
0.3.9 (2013-01-08)
Use unquote_plus instead of unquote for jsonp transport @DustyHarry
0.3.8 (2012-11-15)
Update sockjs-protocol-0.3.3
Fix TypeError in Session.__str__ method
Fix eventsource transport for gevent 1.0b3 version
0.3.7 (2012-07-16)
Explicitly open session before accept any incoming messages, for webscoket transport.
0.3.6 (2012-06-21)
Possible session hijacking #7
Use Configurator action for session gc start. #6
0.3.5 (2012-05-19)
fixed close/closed session states for websocket transport.
removed gunicorn monkey patche. gunicorn 0.14.3 is required.
0.3.4 (2012-05-06)
Fixed datetime serialization, assume all datetime objects in utc tz.
0.3.3 (2012-05-02)
Pass request to session factory
0.3.2 (2012-04-02)
Make ‘cookie_needed’ is configuration option
Update sockjs-protocol 0.3
0.3.1 (2012-03-27)
Fixed python2.6 compatibility. See #1
0.3.0 (2012-03-26)
Hixie 75/76 websocket protocol added
0.2.1 (2012-03-20)
Fixed websocket frame with ‘[]’
Update cors headers for dev protocol compliance
0.2 (2012-03-16)
Fixed ujson support
0.1 (2012-02-23)
Initial release
Metadata
Release files for pyramid_sockjs 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyramid_sockjs-0.3.9.tar.gz | 63.6 kB | Without provenance | Details for pyramid_sockjs-0.3.9.tar.gz |
Release files / pyramid_sockjs-0.3.9.tar.gz
| Download URL | pyramid_sockjs-0.3.9.tar.gz |
|---|---|
| Size | 63.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2c771e068f001fa795e042cc47f1062d02f935aa30761337a98ea172f6d1bdd
|
|
BLAKE2b-256 checksum How to use checksums |
50cac254d2120f36f253c59ef1ce160b3afa2f67806278435bb8cf1ac2a65c12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyramid_sockjs 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.