本文整理汇总了Python中pyramid.config.Configurator.add_sockjs_route方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.add_sockjs_route方法的具体用法?Python Configurator.add_sockjs_route怎么用?Python Configurator.add_sockjs_route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.add_sockjs_route方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: application
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def application(global_config, **settings):
config = Configurator(settings=settings)
config.add_static_view(name="static",path="static", cache_max_age=3600)
config.add_view(index, renderer='piratechat:app.pt')
config.include('pyramid_sockjs')
config.add_sockjs_route(session=MapSession)
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
config.include('pyramid_beaker')
config.include('pyramid_sockjs')
config.include('sams.views')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_sockjs_route(prefix='/api/1.0/sams/ws', session=ClientNotifier)
config.scan()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
set_cache_regions_from_settings(settings)
config = Configurator(settings=settings)
config.include(jsonrpc)
config.add_renderer('ddjson', DDJSONRenderer)
config.registry.settings['mongodb.connector'] = DDMongoConnector(settings['mongodb.uri'], settings['mongodb.db'], settings['mongodb.users'])
if settings.get('mongodb_log.uri', None) is not None:
config.registry.settings['logdb.connector'] = MongoConnector(settings['mongodb_log.uri'], settings['mongodb_log.db'])
config.registry.settings['redis.connector'] = DDRedisConnector(settings['redis.host'], settings['redis.port'], settings['redis.db'], password=settings.get('redis.pass', None))
config.include('pyramid_sockjs')
#config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/app/')
config.add_jsonrpc_endpoint('api', '/app/api/', default_renderer='ddjson')
config.add_sockjs_route(prefix='/__sockjs__', session=DDSockJSSession, sockjs_cdn='https://beta.datadealer.com/sockjs-0.3.4.min.js', cookie_needed=False)
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
session_factory = session_factory_from_settings(settings)
authn_policy = AuthTktAuthenticationPolicy(secret="s0secret")
authz_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
# root_factory='chatapp.security.RootFactory',
authentication_policy=authn_policy,
authorization_policy=authz_policy,
session_factory=session_factory,
)
jinja_env = _get_or_build_default_environment(config.registry)
config.add_route("home", "/")
config.add_sockjs_route("chat-service", session=EchoSession)
config.add_route("broadcast", "/broadcast")
config.scan()
return config.make_wsgi_app()
示例5: on_message
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
'manager': self.manager})
self.shell.write = self.write
self.start()
self.send({'id': 0,
'complete': False,
'more': False,
'out': "Python %s on %s\n" % (sys.version, sys.platform)})
def on_message(self, msg):
self.commands.put_nowait(json.loads(msg))
def on_closed(self):
if self.shell_worker:
self.shell_worker.kill()
if __name__ == '__main__':
""" interactive shell """
from pyramid.config import Configurator
from pyramid_sockjs.paster import gevent_server_runner
config = Configurator()
config.include('pyramid_sockjs')
config.add_sockjs_route('shell', '/++shell++', session=InteractiveShell)
app = config.make_wsgi_app()
gevent_server_runner(app, {}, host='127.0.0.1')
示例6: on_open
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def on_open(self):
self.manager.broadcast("Someone joined.")
def on_message(self, message):
self.manager.broadcast(message)
def on_close(self):
self.manager.broadcast("Someone left.")
if __name__ == '__main__':
""" Simple sockjs chat """
from pyramid.config import Configurator
from pyramid_sockjs.paster import gevent_server_runner
config = Configurator()
config.include('pyramid_sockjs')
config.add_sockjs_route(prefix='/__sockjs__', session=ChatSession)
config.add_route('root', '/')
config.add_view(route_name='root', renderer='__main__:chat.pt')
app = config.make_wsgi_app()
if len(sys.argv) > 1 and (sys.argv[1] == '-g'):
from gunicorn.app.pasterapp import paste_server
paste_server(app, port=8080, worker_class='gevent', workers=1)
else:
gevent_server_runner(app, {}, host='127.0.0.1')
示例7: EchoSession
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
from pyramid_sockjs import Session
class EchoSession(Session):
def on_message(self, msg):
self.send(msg)
@classmethod
def dump_stats(self):
print 'Clients: %d' % (len(self.clients))
if __name__ == '__main__':
from pyramid.config import Configurator
from pyramid_sockjs.paster import gevent_server_runner
config = Configurator()
config.include('pyramid_sockjs')
config.add_sockjs_route(prefix='/echo', session=EchoSession)
app = config.make_wsgi_app()
gevent_server_runner(app, {})
示例8: on_open
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
def on_open(self):
self.manager.broadcast("Someone joined.")
def on_message(self, message):
self.manager.broadcast(message)
def on_close(self):
self.manager.broadcast("Someone left.")
if __name__ == '__main__':
""" Simple sockjs chat """
from pyramid.config import Configurator
from pyramid_sockjs.paster import gevent_server_runner
config = Configurator()
config.include('pyramid_sockjs')
config.add_sockjs_route(session=ChatSession)
config.add_route('root', '/')
config.add_view(route_name='root', renderer='__main__:chat.pt')
app = config.make_wsgi_app()
if len(sys.argv) > 1 and (sys.argv[1] == '-g'):
from gunicorn.app.pasterapp import paste_server
paste_server(app, port=8080, worker_class='gevent', workers=1)
else:
gevent_server_runner(app, {}, host='127.0.0.1')
示例9: Configurator
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_sockjs_route [as 别名]
from pyramid_sockjs.transports.eventsource import EventsourceTransport
from pyramid_sockjs.transports.xhrstreaming import XHRStreamingTransport
from pyramid_sockjs.transports.htmlfile import HTMLFileTransport
HTMLFileTransport.maxsize = 4096
EventsourceTransport.maxsize = 4096
XHRStreamingTransport.maxsize = 4096
XHRStreamingTransport.timing = 0.01
websocket.TIMING = 0.1
jsonp.timing = 0.1
PollingTransport.timing = 0.2
config = Configurator()
config.include('pyramid_sockjs')
config.add_sockjs_route('echo', '/echo', session=EchoSession)
config.add_sockjs_route('wsoff', '/disabled_websocket_echo', session=EchoSession,
disable_transports=('websocket',))
config.add_sockjs_route('close', '/close', session=CloseSession)
config.add_sockjs_route('broadcast', '/broadcast', session=BroadcastSession)
config.add_sockjs_route('cookie', '/cookie_needed_echo',
session=EchoSession, cookie_needed=True)
app = config.make_wsgi_app()
if len(sys.argv) > 1 and (sys.argv[1] == '-g'):
from gunicorn.app.pasterapp import paste_server
paste_server(app, port=8081, worker_class='gevent', workers=1)
else: