本文整理汇总了Python中stalker.db.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stalker.db.DBSession
的用法示例。
在下文中一共展示了DBSession.configure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import configure [as 别名]
def setUpClass(cls):
"""set up the test in class level
"""
DBSession.remove()
DBSession.configure(extension=None)
示例2: tearDownClass
# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import configure [as 别名]
def tearDownClass(cls):
"""cleanup the test
"""
DBSession.remove()
DBSession.configure(extension=None)
示例3: main
# 需要导入模块: from stalker.db import DBSession [as 别名]
# 或者: from stalker.db.DBSession import configure [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
from pyramid.config import Configurator
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
# setup the database to the given settings
from stalker import db
from stalker.db import DBSession
# use the ZopeTransactionExtension for session
db.setup(settings)
DBSession.remove()
DBSession.configure(extension=ZopeTransactionExtension())
# setup authorization and authentication
authn_policy = AuthTktAuthenticationPolicy(
'sosecret',
hashalg='sha512',
callback=group_finder
)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
root_factory='stalker.models.auth.RootFactory'
)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
# Configure Beaker sessions and caching
session_factory = pyramid_beaker.session_factory_from_settings(settings)
config.set_session_factory(session_factory)
pyramid_beaker.set_cache_regions_from_settings(settings)
config.include('pyramid_jinja2')
config.include('pyramid_mailer')
config.add_static_view('static', 'static', cache_max_age=3600)
# *************************************************************************
# Basics
config.add_route('deform_test', '/deform_test')
config.add_route('home', '/')
config.add_route('me_menu', '/me_menu')
config.add_route('signin', '/signin')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('flash_message', '/flash_message')
# addresses like http:/localhost:6543/SPL/{some_path} will let SP to serve
# those files
# SPL : Stalker Pyramid Local
config.add_route(
'serve_files',
'SPL/{partial_file_path:[a-zA-Z0-9/\.]+}'
)
# addresses like http:/localhost:6543/FDSPL/{some_path} will serve the
# files with their original filename in a forced download mode.
# FDSPL : Forced Download Stalker Pyramid Local
config.add_route(
'forced_download_files',
'FDSPL/{partial_file_path:[a-zA-Z0-9/\.]+}'
)
logger.debug(defaults.server_side_storage_path + '/{partial_file_path}')
# *************************************************************************
# DATA VIEWS
# *************************************************************************
# *************************************************************************
# Entities
config.add_route('get_search_result', '/search') # json
config.add_route('list_search_result', '/list/search_results')
config.add_route('submit_search', '/submit_search')
config.add_route('upload_entity_thumbnail_dialog', 'entities/{id}/thumbnail/upload/dialog')
config.add_route('upload_entity_reference_dialog', 'entities/{id}/references/upload/dialog')
config.add_route('create_entity_users_dialog', 'entities/{id}/users/create/dialog')
config.add_route('append_users_to_entity_dialog', 'entities/{id}/users/append/dialog')
config.add_route('append_users_to_entity', 'entities/{id}/users/append')
config.add_route('remove_entity_from_entity_dialog','entities/{id}/{entity_id}/remove/dialog')
config.add_route('remove_entity_from_entity', 'entities/{id}/{entity_id}/remove')
config.add_route('delete_entity_dialog', 'entities/{id}/delete/dialog')
config.add_route('delete_entity', 'entities/{id}/delete')
config.add_route('create_entity_note', 'entities/{id}/note/create')
config.add_route('delete_note_dialog', 'notes/{id}/delete/dialog')
config.add_route('delete_note', 'notes/{id}/delete')
# get routes returns json
config.add_route('get_entity', 'entities/{id}/')
#.........这里部分代码省略.........