本文整理汇总了Python中pyramid_beaker.session_factory_from_settings函数的典型用法代码示例。如果您正苦于以下问题:Python session_factory_from_settings函数的具体用法?Python session_factory_from_settings怎么用?Python session_factory_from_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_factory_from_settings函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
initialize_sql(settings)
session_factory = session_factory_from_settings(settings)
set_cache_regions_from_settings(settings)
authentication_policy = AuthTktAuthenticationPolicy('somesecret')
authorization_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
session_factory=session_factory,
authentication_policy=authentication_policy,
authorization_policy=authorization_policy
)
config.add_subscriber(add_renderer_globals, BeforeRender)
config.add_subscriber(csrf_validation, NewRequest)
config.add_mako_renderer(".html")
config.add_static_view("static", "patchman:static", cache_max_age=3600)
config.add_static_view("store",settings["storage"], cache_max_age=3600)
MyRoutes(config)
config.scan()
return config.make_wsgi_app()
开发者ID:ricardosiri68,项目名称:patchcap,代码行数:31,代码来源:__init__.py
示例2: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
session_factory = session_factory_from_settings(settings)
set_cache_regions_from_settings(settings)
config = Configurator(settings=settings, session_factory=session_factory)
config.set_authentication_policy(AuthTktAuthenticationPolicy(
settings['authtkt.secret']))
config.set_authorization_policy(ACLAuthorizationPolicy())
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('submit', '/submit')
config.add_route('details', '/details')
config.add_route('admin', '/admin')
config.add_route('csv', '/csv')
config.add_route('approve', '/approve')
config.add_route('accept', '/accept')
config.add_route('save_address', '/save_address')
config.include('pyramid_mailer')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_view('fedorasummerofhardware.views.login_view',
renderer='fedorasummerofhardware:templates/login.mak',
context=Forbidden)
config.scan()
return config.make_wsgi_app()
开发者ID:fedora-infra,项目名称:fedora-openhw2012,代码行数:27,代码来源:__init__.py
示例3: main
def main(self, global_config, **settings):
settings['su.using_tm'] = True
config = global_config
config.add_settings(settings)
config.registry.registerUtility(Activation, IActivationClass)
config.registry.registerUtility(User, IUserClass)
def index(request):
return Response('index!')
config.add_route('index', '/')
config.add_view(index, route_name='index')
authz_policy = ACLAuthorizationPolicy()
config.set_authorization_policy(authz_policy)
authn_policy = AuthTktAuthenticationPolicy('secret')
config.set_authentication_policy(authn_policy)
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
config.registry.registerUtility(DBSession, IDBSession)
if settings.get('su.require_activation', True):
config.include('pyramid_mailer')
config.include('pyramid_mako')
config.include('horus')
app = config.make_wsgi_app()
return app
开发者ID:Happystation,项目名称:horus,代码行数:35,代码来源:__init__.py
示例4: main
def main(global_config, **app_settings):
""" This function returns a Pyramid WSGI application.
"""
settings = global_config
settings.update(app_settings)
initialize_web_database(settings)
session_factory = session_factory_from_settings(settings)
auth_policy = AuthTktAuthenticationPolicy(
settings['auth_tkt.secret'],
callback=models.user.get_user_groups,
hashalg='sha512',
)
set_cache_regions_from_settings(settings)
config = Configurator(settings=settings,
request_factory=NDRequest,
session_factory=session_factory,
root_factory=_rsr.Root,
authentication_policy=auth_policy)
config.include('pyramid_mako')
config.include('pyramid_layout')
config.include('notification_demo.lib.client_script')
config.include("pyramid_vgid_oauth2")
config.include("notification_demo.views")
config.include("notification_demo.lib.notification")
config.add_static_view('static', STATIC_DIR, cache_max_age=3600)
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
开发者ID:phamthanhnhan14,项目名称:noti_copy,代码行数:31,代码来源:__init__.py
示例5: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
init_DBSession(settings)
config = Configurator(settings=settings)
config.include('pyramid_mako')
# Beaker Session Manager
import pyramid_beaker
session_factory = pyramid_beaker.session_factory_from_settings(settings)
config.set_session_factory(session_factory)
# Parse/Convert setting keys that have specifyed datatypes
for key in config.registry.settings.keys():
config.registry.settings[key] = convert_str_with_type(config.registry.settings[key])
config.add_static_view('static', 'static', cache_max_age=3600)
# Routes
def append_format_pattern(route):
return re.sub(r'{(.*)}', r'{\1:[^/\.]+}', route) + r'{spacer:[.]?}{format:(%s)?}' % '|'.join(registered_formats())
config.add_route('home' , append_format_pattern('/') )
config.add_route('position_update', append_format_pattern('/position_update'))
config.add_route('position_get' , append_format_pattern('/position_get') )
config.add_route('last_checkin' , append_format_pattern('/last_checkin') )
config.add_route('near_stops' , append_format_pattern('/near_stops') )
config.add_route('near_bus' , append_format_pattern('/near_bus') )
config.scan()
return config.make_wsgi_app()
开发者ID:JoeReid,项目名称:TrackMyBus,代码行数:33,代码来源:__init__.py
示例6: main
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
authentication_policy = AuthTktAuthenticationPolicy('somesecret')
authorization_policy = ACLAuthorizationPolicy()
session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
root_factory=Root,
)
config.set_session_factory(session_factory)
# jinja 2 config
config.add_jinja2_search_path("chessnut:templates")
config.include('pyramid_jinja2')
# views
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('twauth', '/twauth')
config.add_route('index', '/index')
config.add_route('register', '/register')
config.add_route('mentions', '/mentions')
config.scan()
return config.make_wsgi_app()
开发者ID:tsnaomi,项目名称:Chessnut,代码行数:30,代码来源:__init__.py
示例7: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['db'] = {'host':'localhost', 'port': 27017}
session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,session_factory=session_factory)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_renderer('jsonp', JSONP(param_name = 'callback'))
config.add_route('home', '/')
config.add_route('home_jiang', '/home')
config.add_route('index', '/index')
config.add_route('preview', '/i/{short_url}')
config.add_route('img', '/html/img/{filename}')
config.add_route('test', '/test')
config.add_route('create', '/create')
config.add_route('get_info', '/get_info')
config.add_route('pull', '/pull')
config.add_route('tencent', '/qq')
config.add_route('login', '/login')
config.add_route('site_view', '/site_view')
config.add_route('register', '/register')
config.add_route('qqlogin', '/qqlogin')
config.scan()
return config.make_wsgi_app()
开发者ID:adamwen,项目名称:quickshare,代码行数:30,代码来源:__init__.py
示例8: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, "sqlalchemy.")
settings["db.sessionmaker"] = DBSession
DBSession.configure(bind=engine)
Base.metadata.bind = engine
Base.metadata.create_all(engine)
initialize_sql(engine, [populate, populate_wiki, populate_feeds])
session_factory = session_factory_from_settings(settings)
root_factory = "trumpet.resources.RootGroupFactory"
request_factory = "trumpet.request.AlchemyRequest"
config = Configurator(
settings=settings,
root_factory=root_factory,
request_factory=request_factory,
authentication_policy=authn_policy,
authorization_policy=authz_policy,
session_factory=session_factory,
)
configure_static(config)
# config.include('pyramid_fanstatic')
configure_base_layout(config)
config.add_static_view("static", "static", cache_max_age=3600)
config.add_route("home", "/")
config.add_view("plum.views.MainViewer", route_name="home", renderer=basetemplate, layout="base")
configure_login(config)
configure_rssviewer(config, "/rssviewer")
configure_wiki(config, "/wiki")
return config.make_wsgi_app()
开发者ID:umeboshi2,项目名称:raspbian-setup,代码行数:34,代码来源:__init__.py
示例9: main
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
session_factory = session_factory_from_settings(settings)
set_cache_regions_from_settings(settings)
config = Configurator(settings=settings)
config.set_session_factory(session_factory)
start_scheduler()
config.include('pyramid_mako')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('data', 'data', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('uiks', '/uik/all')
config.add_route('stat_json', '/uik/stat/json')
config.add_route('statistic', '/uik/stat')
config.add_route('uik_export_page', '/uik/export')
config.add_route('uik', '/uik/{id}')
config.add_route('uik_block', '/uik/block/{id}')
config.add_route('uik_unblock', '/uik/unblock/{id}')
config.add_route('uik_by_off_number', '/uik/{region_id}/{official_number}')
config.add_route('register', '/register')
config.add_route('logs', '/logs')
config.add_route('uikp_all', '/uikp/all')
config.add_route('uikp', '/uikp/{id}')
config.scan()
return config.make_wsgi_app()
开发者ID:nextgis,项目名称:uik_geo,代码行数:27,代码来源:__init__.py
示例10: main
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
session_factory = session_factory_from_settings(settings)
authn_policy = AuthTktAuthenticationPolicy(settings['auth.secret'],
callback=User.groupfinder)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
session_factory=session_factory,
authentication_policy=authn_policy,
authorization_policy=authz_policy,
root_factory=Root
)
config.add_static_view('images', 'duckly:static/images')
config.add_static_view('js', 'duckly:static/js')
config.add_static_view('css', 'duckly:static/css')
config.add_google_oauth2_login_from_settings(prefix='google.')
config.add_route('logout', '/logout')
config.add_route('home.unauth', '/', custom_predicates=(unauthorized,))
config.add_route('home', '/', custom_predicates=(authorized,))
config.add_route('signup', '/signup')
config.scan()
return config.make_wsgi_app()
开发者ID:jaminh,项目名称:duckly-server,代码行数:30,代码来源:__init__.py
示例11: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
LogSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
my_session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,
root_factory='loginproject.models.RootFactory',
#session_factory=my_session_factory
)
config.include('pyramid_beaker')
config.set_session_factory(my_session_factory)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.add_request_method(models.get_user, 'user', reify=True)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('protected', '/protected')
config.add_route('login', '/login/{provider}')
config.add_route('logout', '/logout')
config.scan()
return config.make_wsgi_app()
开发者ID:petertirrell,项目名称:LoginProject,代码行数:34,代码来源:__init__.py
示例12: main
def main(global_config, **settings):
config = Configurator(settings=settings)
config.add_route('index', '/')
authn_policy = AuthTktAuthenticationPolicy('secret', callback=groupfinder)
config.set_authentication_policy(authn_policy)
authz_policy = ACLAuthorizationPolicy()
config.set_authorization_policy(authz_policy)
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
engine = engine_from_config(settings, prefix='sqlalchemy.')
DBSession.configure(bind=engine)
config.registry.registerUtility(DBSession, ISUSession)
config.include('pyramid_tm')
if settings.get('su.require_activation', True):
config.include('pyramid_mailer')
config.scan('demo')
config.include('pyramid_signup')
app = config.make_wsgi_app()
return app
开发者ID:whitmo,项目名称:pyramid_signup,代码行数:31,代码来源:__init__.py
示例13: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings["g"] = g = Globals(**settings)
config = Configurator(settings=settings
, session_factory = session_factory_from_settings(settings)
, locale_negotiator = DefaultLocaleNegotiator(g.available_locales, g.default_locale_name))
extend_request(config)
config.add_translation_dirs('formencode:i18n')
config.add_translation_dirs('larryslist:locale')
config.add_renderer(".html", renderer_factory)
config.add_renderer(".xml", renderer_factory)
config.add_renderer('json', jsonRenderer)
config.add_subscriber(add_localizer, 'pyramid.events.NewRequest')
config.add_subscriber(context_authorization, 'pyramid.events.ContextFound')
config.add_subscriber(add_renderer_variables, 'pyramid.events.BeforeRender')
if g.is_debug:
config.add_static_view('static', 'static', cache_max_age=3600)
if settings['deploy.admin'] == 'True':
config.include("larryslist.admin.apps", route_prefix='/admin')
if settings['deploy.website']:
config.include("larryslist.website.apps")
if settings['deploy.reports'] =='True':
config.include("larryslist.reports.apps", route_prefix='/reports')
config.scan()
return config.make_wsgi_app()
开发者ID:larryslist,项目名称:larryslist_pub,代码行数:35,代码来源:__init__.py
示例14: main
def main(global_config, **settings):
"""
Main function : returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
auth_policy = SessionAuthenticationPolicy(callback=build_avatar)
acl_policy = ACLAuthorizationPolicy()
session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,
session_factory=session_factory,
authentication_policy=auth_policy,
authorization_policy=acl_policy,
root_factory=RootFactory
)
config.add_static_view('static', 'crmbase:static', cache_max_age=3600)
config.add_route('index', '/')
# REST API
## using the four HTTP methods (POST, GET, PUT, DELETE),
## translating them in (add, get, update, delete)
## and the two following routes,
## we can get a very clean REST API
config.add_route("users", "/users")
config.add_route("user", "/users/{uid}")
config.add_route("contacts", "/contacts")
config.add_route("login", "/login")
config.add_route("logout", "/logout")
return config.make_wsgi_app()
开发者ID:faddai,项目名称:pyramidCrm,代码行数:30,代码来源:__init__.py
示例15: main
def main(global_config, **settings):
authn_policy = AuthTktAuthenticationPolicy(settings.get('pumbaa.secret'), callback=group_finder)
authz_policy = ACLAuthorizationPolicy()
pumbaa_session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,
root_factory='pumbaa.acl.RootFactory',
authentication_policy=authn_policy,
authorization_policy=authz_policy,
session_factory = pumbaa_session_factory)
models.initial(settings)
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='velruse.facebook.')
config.include('velruse.providers.google_oauth2')
config.add_google_oauth2_login_from_settings(prefix='velruse.google.')
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='velruse.twitter.')
add_routes(config)
config.scan('pumbaa.views')
from .request_factory import RequestWithUserAttribute
config.set_request_factory(RequestWithUserAttribute)
return config.make_wsgi_app()
开发者ID:nolifelover,项目名称:pumbaa,代码行数:27,代码来源:__init__.py
示例16: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
models.initialize(engine)
config = Configurator(settings=settings,
root_factory='bonanza.lib:RootFactory',
session_factory=session_factory_from_settings(settings),
# authentication_policy=AuthTktAuthenticationPolicy(
# '5e04c5f06208def3c5becd6db74f8d11733a912a',
# callback=bonanza.security.lookup_userid),
# authorization_policy=ACLAuthorizationPolicy()
)
config.include('pyramid_jinja2')
config.include('pyramid_scss')
config.add_static_view('static', 'bonanza:static', cache_max_age=3600)
# entity
config.add_route('home', '/')
config.add_view(route_name='home', view='bonanza.controllers.home.get_index',
renderer='/home/index.jinja2', request_method='GET')
# scss
config.add_route('css', '/css/{stylesheet}.css')
config.add_view(route_name='css', view='bonanza.controllers.static.get_css',
renderer='scss', request_method='GET')
config.commit()
add_template_filters(config)
return config.make_wsgi_app()
开发者ID:jessedhillon,项目名称:bonanza,代码行数:32,代码来源:__init__.py
示例17: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
session_config = session_factory_from_settings(settings)
config = Configurator(settings=settings, session_factory=session_config, root_factory='.models.RootFactory')
config.set_authentication_policy(authetntication_policy)
config.set_authorization_policy(authorization_policy)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_renderer('.html', mako_factory)
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('about', '/about')
config.add_route('contact', '/contact')
config.add_route('income', '/income')
config.add_route('income_category', '/income-category')
config.add_route('expense', '/expense')
config.add_route('expense_category', '/expense-category')
config.add_route('balance', '/balance')
config.add_subscriber('.subscribers.csrf_validation', NewRequest)
config.scan()
return config.make_wsgi_app()
开发者ID:RapicMilan,项目名称:Personal-finance-manager,代码行数:26,代码来源:__init__.py
示例18: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include("solute.epfl")
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
config.add_static_view(name='static',
path='epfl_pyramid_barebone:static',
cache_max_age=3600)
authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
temp_data_provider = epfltempdata.LocalMemoryProvider(config)
config.set_tempdata_provider(temp_data_provider)
nodeglobal_data_provider = epfltempdata.LocalMemoryProvider(config)
config.set_nodeglobaldata_provider(nodeglobal_data_provider)
config.scan()
return config.make_wsgi_app()
开发者ID:JustusW,项目名称:pyramid_epfl,代码行数:26,代码来源:__init__.py
示例19: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('register', '/register')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('upload', '/upload')
config.scan()
''' set session factory '''
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
''' make user variable available in request '''
config.add_request_method(get_user, 'user', reify=True)
''' Connect to mongodb '''
connect('tigress')
return config.make_wsgi_app()
开发者ID:haoericliu,项目名称:haoliu,代码行数:25,代码来源:__init__.py
示例20: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
session_factory = session_factory_from_settings(settings)
config = Configurator(settings=settings,
session_factory=session_factory)
config.include('pyramid_mailer')
config.add_translation_dirs(
'colander:locale/',
'deform:locale/',
'c3sintent:locale/')
config.add_static_view('static',
'c3sintent:static', cache_max_age=3600)
config.add_subscriber('c3sintent.subscribers.add_base_template',
'pyramid.events.BeforeRender')
config.add_subscriber('c3sintent.subscribers.add_locale_to_cookie',
'pyramid.events.NewRequest')
# home /
# intent form
config.add_route('intent', '/')
config.add_route('disclaimer', '/disclaimer')
config.add_route('faq', '/faq')
config.add_route('success', '/success')
config.add_route('success_check_email', '/check_email')
config.add_route('success_verify_email', '/verify/{email}/{code}')
config.add_route('success_pdf', '/C3S_DeclarationOfIntent_{namepart}.pdf')
config.scan()
return config.make_wsgi_app()
开发者ID:C3S,项目名称:C3SIntent,代码行数:33,代码来源:__init__.py
注:本文中的pyramid_beaker.session_factory_from_settings函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论