本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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
示例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()
示例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()
示例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()