def load(self): params = self.params.copy() params.update({'APPLICATION_URLS': self.urls}) settings = cms.get_settings(__file__, self.settings_file, **params) from djpsite.apps.geo import Geo from djpsite.apps.ws import WebSocketApps Geo.username = settings.GEOUSERNAME # Create the permission handler permissions = PermissionHandler(settings) permissions.auth_backends.append(SocialAuthBackend()) backend = permissions.auth_backends[0] # AUTHENTICATION MIDDLEWARE self.add_wsgi_middleware(permissions.header_authentication_middleware) self.add_wsgi_middleware(permissions.request_middleware()) self.add_response_middleware(permissions.response_middleware()) # WEB SOCKET MIDDLEWARE self.add_wsgi_middleware(ws.WebSocket(WebSocketApps('/ws/', settings))) # The root site site = cms.Site(settings, permissions=permissions) site.submit_data_middleware.add(cms.Referrer) # Add CSRF submit middleware site.submit_data_middleware.add(CSRF) # admin site settings = cms.get_settings(__file__, self.settings_file, APPLICATION_URLS=admin.make_admin_urls()) site.addsite(settings, route='/admin/') self.page_layouts(site) return site
def setup(self): router = HttpBin('/') return wsgi.WsgiHandler([ wsgi.clean_path_middleware, wsgi.cookies_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self, environ): router = HttpBin('/') return wsgi.WsgiHandler([ ExpectFail('expect'), wsgi.wait_for_body_middleware, wsgi.clean_path_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR, show_indexes=True), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self): '''This method is called once only to setup the WSGI application handler as described in :ref:`lazy wsgi handler <wsgi-lazy-handler>` section. It creates a :ref:`publish/subscribe handler <apps-pubsub>` and subscribe it to the ``webchat`` channel.''' backend = self.cfg.get('backend_server') self.pubsub = pubsub.PubSub(backend, encoder=self.encode_message) self.pubsub.subscribe('webchat') return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home_page), ws.WebSocket('/message', Chat(self.pubsub)), wsgi.Router('/rpc', post=Rpc(self.pubsub)) ])
def setup(self, environ): '''Called once only to setup the WSGI application handler. Check :ref:`lazy wsgi handler <wsgi-lazy-handler>` section for further information. ''' cfg = environ['pulsar.cfg'] loop = environ['pulsar.connection']._loop self.store = data.create_store(cfg.data_store, loop=loop) pubsub = self.store.pubsub(protocol=WsProtocol()) channel = '%s_messages' % self.name pubsub.subscribe(channel) middleware = [wsgi.Router('/', get=self.home_page), ws.WebSocket('/message', PhilosopherWs(pubsub, channel)), wsgi.FileRouter('/favicon.ico', FAVICON), wsgi.MediaRouter('media', ASSET_DIR)] return wsgi.WsgiHandler(middleware)
def setup(self, environ): return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home), ws.WebSocket('/data', Graph(), parser_factory=self._factory), ws.WebSocket('/echo', Echo(), parser_factory=self._factory) ])
def __init__(self): self._web_socket = ws.WebSocket('/message', Chat())
def setup(self, environ): return wsgi.WsgiHandler([ ws.WebSocket('/message', WsMail()), wsgi.MediaRouter('/media', ASSET_DIR), wsgi.Router('/', get=self.home) ])
def setup(self, environ): wm = ws.WebSocket('/', TitanRPC()) return wsgi.WsgiHandler(middleware=[wm], async=True)
def setup(self): return wsgi.WsgiHandler([ wsgi.Router('/', get=self.home), ws.WebSocket('/data', Graph()), ws.WebSocket('/echo', Echo()) ])
def server(): wm = ws.WebSocket('/', EchoRPC()) app = wsgi.WsgiHandler(middleware=[wm]) return wsgi.WSGIServer(callable=app)