/usr/lib/python2.7/dist-packages/socketio/sdjango.py is in python-socketio 0.3.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import logging
from socketio import socketio_manage
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.utils.importlib import import_module
# for Django 1.3 support
try:
from django.conf.urls import patterns, url, include
except ImportError:
from django.conf.urls.defaults import patterns, url, include
SOCKETIO_NS = {}
LOADING_SOCKETIO = False
def autodiscover():
"""
Auto-discover INSTALLED_APPS sockets.py modules and fail silently when
not present. NOTE: socketio_autodiscover was inspired/copied from
django.contrib.admin autodiscover
"""
global LOADING_SOCKETIO
if LOADING_SOCKETIO:
return
LOADING_SOCKETIO = True
import imp
from django.conf import settings
for app in settings.INSTALLED_APPS:
try:
app_path = import_module(app).__path__
except AttributeError:
continue
try:
imp.find_module('sockets', app_path)
except ImportError:
continue
import_module("%s.sockets" % app)
LOADING_SOCKETIO = False
class namespace(object):
def __init__(self, name=''):
self.name = name
def __call__(self, handler):
SOCKETIO_NS[self.name] = handler
return handler
@csrf_exempt
def socketio(request):
try:
socketio_manage(request.environ, SOCKETIO_NS, request)
except:
logging.getLogger("socketio").error("Exception while handling socketio connection", exc_info=True)
return HttpResponse("")
urls = patterns("", (r'', socketio))
|