本文整理汇总了Python中pyramid.configuration.Configurator.set_session_factory方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.set_session_factory方法的具体用法?Python Configurator.set_session_factory怎么用?Python Configurator.set_session_factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.set_session_factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import set_session_factory [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
tictactroll.gamestate.set_db_path(settings.get('db_path'))
config.add_view("tictactroll.views.game", name="game",
renderer="tictactroll:templates/game.mako")
config.add_view("tictactroll.views.about", name="about",
renderer="tictactroll:templates/about.mako")
config.add_view("tictactroll.views.welcome",
renderer="tictactroll:templates/welcome.mako")
config.add_view("tictactroll.views.enter_game", name="enter_game")
config.add_view("tictactroll.views.new_game", name="new_game")
config.add_view("tictactroll.views.add_grid", name="add_grid",
renderer="json")
config.add_view("tictactroll.views.next_troll_grid",
name="next_troll_grid", renderer="json")
config.add_view("tictactroll.views.gameover_html", name="gameover",
renderer="tictactroll:templates/gameover.mako")
config.add_static_view("static", "tictactroll:static")
config.end()
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import set_session_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
from pyramid.configuration import Configurator
config = Configurator(settings=settings)
config.add_renderer(name = 'nt', factory='.renderers.NTriplesGraphRenderer')
config.add_renderer(name = 'rdfxml', factory='.renderers.RDFXMLGraphRenderer')
config.add_renderer(name = 'n3', factory='.renderers.N3GraphRenderer')
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
config.registry['sparql.url'] = settings['sparql.url']
config.add_static_view('static', 'sparql_shim:static/')
config.add_handler('direct_graph', '/{name:.+}', '.handlers:GraphHandler',
action='graph')
config.add_handler('indirect_graph', '/', '.handlers:GraphHandler',
action='graph')
config.scan('sparql_shim.subscribers')
return config.make_wsgi_app()