本文整理汇总了Python中pyramid.config.Configurator.set_request_factory方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.set_request_factory方法的具体用法?Python Configurator.set_request_factory怎么用?Python Configurator.set_request_factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.set_request_factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
initialize_sql(settings)
config = Configurator(settings=settings)
config.include('pyramid_tm')
config.include('pyramid_redis_sessions')
config.include('pyramid_jinja2')
config.add_jinja2_search_path('potte:templates/')
# auth
authn_policy = AuthTktAuthenticationPolicy(
settings['authtkt.secret'],
callback=auth_groupfinder,
hashalg='sha512',
)
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
# request
config.set_request_factory(RequestWithUserAttribute)
config.include('.urls')
config.scan()
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Update the settings with the current app root path
settings['app_root'] = abspath(dirname(dirname(__file__)))
initialize_sql(settings)
authn_policy = AuthTktAuthenticationPolicy(
settings.get('auth.secret'),
callback=UserMgr.auth_groupfinder)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings,
root_factory='bookie.RootFactory',
authentication_policy=authn_policy,
authorization_policy=authz_policy)
config.set_request_factory(RequestWithUserAttribute)
config = build_routes(config)
config.add_static_view('static', 'bookie:static')
config.scan('bookie.views')
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
from nokkhumapi.security import TokenAuthenticationPolicy
authn_policy = TokenAuthenticationPolicy()
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, root_factory='nokkhumapi.acl.RootFactory',
authentication_policy=authn_policy, authorization_policy=authz_policy)
from .routing import add_routes
add_routes(config)
config.scan('nokkhumapi.views')
from .models import initial
initial(config.registry.settings)
modify_json_renderer(config)
from .security import SecretManager, RequestWithUserAttribute
config.set_request_factory(RequestWithUserAttribute)
secret_manager = SecretManager(settings.get('nokkhum.auth.secret'))
config.registry.settings['secret_manager'] = secret_manager
config.add_subscriber(add_response_callback, NewRequest)
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.set_request_factory(MyRequest)
config.include('pyramid_mako')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('apidocs', '/apidocs')
config.add_route('error', '/error')
config.add_route('expired', '/expired')
config.add_route('secret', '/secret')
config.add_route('retrieve', '/retrieve/{uuid}')
config.add_route('api', '/api')
config.add_route('api_secret', '/api/v1/secret')
config.add_route('api_secret:uuid', '/api/v1/secret/{uuid}')
config.add_tween('angerona2.utilities.hack_thread_name_tween_factory')
config.scan()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
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()
示例6: application
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def application(environ, start_response):
Init_App()
config = Configurator(authentication_policy=authentication_policy,
authorization_policy=authorization_policy)
# settings=settings)
config.add_renderer('.html', mako_factory) #Make it so .html files are recognized and goes thru the MAKO factory
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/') #sign in page
config.add_route('Sign_Out', '/sign_out') #sign out (this gets redirected back to 'home' or '/'
config.add_route('FAQ', '/FAQ') #sign out (this gets redirected back to 'home' or '/'
config.add_route('One_World', '/One_World') #sign out (this gets redirected back to 'home' or '/'
config.add_route('Star_Alliance', '/Star_Alliance') #sign out (this gets redirected back to 'home' or '/'
config.add_route('Sky_Team', '/Sky_Team') #sign out (this gets redirected back to 'home' or '/'
config.add_route('test_page', '/test_page') #sign out (this gets redirected back to 'home' or '/'
config.add_route('pointtracker', '/pointtracker') #main info page with account data
config.set_request_factory(PTRequest) #Hook in our custom Request Object
config.scan('pointtracker.views') #scan our pointtracker project directory for any Views (all of ours are in views.py)
app = config.make_wsgi_app()(environ, start_response)
return app
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Update the settings with the current app root path
settings["app_root"] = abspath(dirname(dirname(__file__)))
initialize_sql(settings)
authn_policy = AuthTktAuthenticationPolicy(settings.get("auth.secret"), callback=UserMgr.auth_groupfinder)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
root_factory="bookie.RootFactory",
authentication_policy=authn_policy,
authorization_policy=authz_policy,
)
config.set_request_factory(RequestWithUserAttribute)
config = build_routes(config)
config.add_static_view("static", "bookie:static")
config.add_renderer("jsonp", JSONP(param_name="callback"))
config.scan("bookie.views")
return config.make_wsgi_app()
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main():
Init_App()
# Globalvars.AES_Key = mtk.read_file("AES_Key.dng")
# Globalvars.Saltstring = mtk.read_file("Saltstring.dng")
# Init_PointTracker_Database() #Initialize the PointTracker Mongo database
# config = Configurator(authentication_policy=auth.authentication_policy,
# authorization_policy=auth.authorization_policy,
# settings=settings)
config = Configurator(authentication_policy=authentication_policy,
authorization_policy=authorization_policy)
config.add_renderer('.html', mako_factory) #Make it so .html files are recognized and goes thru the MAKO factory
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/') #sign in page
config.add_route('Sign_Out', '/sign_out') #sign out (this gets redirected back to 'home' or '/'
config.add_route('pointtracker', '/pointtracker') #main info page with account data
config.set_request_factory(PTRequest) #Hook in our custom Request Object
config.scan('pointtracker.views') #scan our pointtracker project directory for any Views (all of ours are in views.py)
app = config.make_wsgi_app()
return app
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
backends.Servers = backends.ServerList(settings['sqlalchemy.urls'])
#MySession.configure(bind=mysql_engine)
#MyBase.metadata.bind = mysql_engine
#Base.metadata.create_all(engine)
#e("show tables").fetchall()
config = Configurator(settings=settings)
config.set_root_factory(get_root)
my_session_factory = SignedCookieSessionFactory('itsaseekreet')
config.set_session_factory(my_session_factory)
config.set_request_factory(CustomRequest)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
#config.add_route('home', '/')
#config.add_route('left_menu', '/')
config.scan()
return config.make_wsgi_app()
示例10: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# initializing DBSession and Base
# engine = engine_from_config(settings, 'sqlalchemy.')
# DBSession.configure(bind=engine)
# Base.metadata.bind = engine
config = Configurator(settings=settings)
# initializing session
# TODO: turn on the secure=True when using https
config.include("pyramid_beaker")
config.set_session_factory(session_factory_from_settings(settings))
authn_policy = AuthTktAuthenticationPolicy("sosecret", callback=groupfinder, hashalg="sha512")
authz_policy = ACLAuthorizationPolicy()
# config = Configurator(settings=settings,
# root_factory='lookchic.models.RootFactory')
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.include("pyramid_chameleon")
config.add_static_view("static", "static", cache_max_age=3600)
config.set_request_factory(request_factory)
# config.add_route('home', '/')
# User Auth Service
config.add_route("signup", "/signup")
config.add_route("login", "/login")
config.add_route("logout", "/logout")
# User Post Service
config.add_route("main", "/main")
config.add_route("post", "/post")
config.add_route("addcomment", "/addcomment")
config.add_route("addlike", "/addlike")
config.add_route("addfavorite", "/addfavorite")
# User Profile Service
config.add_route("userprofile", "/userprofile")
config.add_route("userposts", "/userposts")
config.add_route("userfav", "/userfav")
# User Search Service
config.add_route("search", "/search")
# config.add_route('add_page', '/add_page/{pagename}')
# config.add_route('edit_page', '/{pagename}/edit_page')
# config.add_route('home', '/')
# config.scan(".utility_views")
config.scan(".views")
# config.scan(".events")
return config.make_wsgi_app()
示例11: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
# defaults
if 'mako.directories' not in settings:
settings['mako.directories'] = 'marteauweb:templates'
session_factory = session_factory_from_settings(settings)
# configure the waitress logger
logger = logging.getLogger('waitress')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
# creating the config and the queue
config = Configurator(settings=settings, session_factory=session_factory)
config.registry['queue'] = queue.Queue()
# Use our custom Request class
config.set_request_factory(Request)
# Both of our chosen policies configure a "forbidden view" to handle
# unauthenticated access. We have to resolve this conflict by explicitly
# picking which one we want to use.
config.add_forbidden_view("pyramid_persona.views.forbidden")
# routing
config.add_route('index', '/')
config.add_route('profile', '/profile')
config.add_route('purge', '/purge')
config.add_route('reset', '/reset')
config.add_route('test', '/test')
config.add_route('cancel', '/test/{jobid}/cancel')
config.add_route('delete', '/test/{jobid}/delete')
config.add_route('replay', '/test/{jobid}/replay')
config.add_route('job', '/test/{jobid}')
config.add_route('nodes', '/nodes')
config.add_route('node_enable', '/nodes/{name}/enable')
config.add_route('node_test', '/nodes/{name}/test')
config.add_route('node', '/nodes/{name}')
config.add_route('report_index', '/report/{jobid}')
config.add_route('report_file', '/report/{jobid}/{filename:.*}')
config.add_route('docs_file', '/docs/{file:.*}')
config.add_route('docs_index', '/docs')
config.add_route('addjob', '/addjob')
config.add_route('fixture_options', '/fixture_options/{fixture:.*}')
config.add_route('project_options', '/project_options/{project:.*}')
config.add_route('hosts', '/hosts')
config.add_route('verify_host', '/hosts/{host:.*}/verify')
config.add_route('host', '/hosts/{host:.*}')
config.add_static_view('media', 'marteauweb:media/')
config.add_route('karaoke', '/media/marteau.kar')
config.add_route('socket_io', 'socket.io/*remaining')
config.scan("marteauweb.views")
config.scan("marteauweb.socketio_service")
return config.make_wsgi_app()
示例12: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
session_factory = session_factory_from_settings(settings)
authn_policy = AuthTktAuthenticationPolicy(
's0secret!!',
callback=groupfinder,)
authz_policy = ACLAuthorizationPolicy()
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings,
authentication_policy=authn_policy,
authorization_policy=authz_policy,
session_factory=session_factory,
root_factory=Root)
# using a custom request with user information
config.set_request_factory(RequestWithUserAttribute)
config.include('pyramid_mailer')
config.add_translation_dirs(
'colander:locale/',
'deform:locale/',
'c3smembership:locale/')
config.add_static_view('static',
'c3smembership:static', cache_max_age=3600)
config.add_subscriber('c3smembership.subscribers.add_base_template',
'pyramid.events.BeforeRender')
config.add_subscriber('c3smembership.subscribers.add_locale_to_cookie',
'pyramid.events.NewRequest')
# home is /, the membership application form
config.add_route('join', '/')
# info pages
config.add_route('disclaimer', '/disclaimer')
config.add_route('faq', '/faq')
config.add_route('statute', '/statute')
config.add_route('manifesto', '/manifesto')
# success and further steps
config.add_route('success', '/success')
config.add_route('success_check_email', '/check_email')
config.add_route('verify_email_password', '/verify/{email}/{code}')
config.add_route('success_pdf', '/C3S_SCE_AFM_{namepart}.pdf')
# routes & views for staff
config.add_route('dashboard', '/dashboard/{number}')
config.add_route('detail', '/detail/{memberid}')
config.add_route('switch_sig', '/switch_sig/{memberid}')
config.add_route('switch_pay', '/switch_pay/{memberid}')
config.add_route('delete_entry', '/delete/{memberid}')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.scan()
return config.make_wsgi_app()
示例13: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [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.add_static_view('static', 'static', cache_max_age=3600)
secret = config.get_settings().get('slowroll.secret')
if not secret:
secret = 'yellr_secret'
httponly = False if config.get_settings().get('slowroll.header_httponly') == 'false' else True
secure = False if config.get_settings().get('slowroll.header_secure') == 'false' else True
my_session_factory = SignedCookieSessionFactory(
secret,
httponly=httponly,
secure=secure,
)
config.set_session_factory(my_session_factory)
# enables cors so the app can do AJAX calls.
config.set_request_factory(request_factory)
config.add_route('/', '/')
config.add_route('/login', '/login')
config.add_route('/validate', '/validate')
config.add_route('/admin', '/admin')
config.add_route('/api/users/login', '/api/users/login')
config.add_route('/api/users/logout', '/api/users/logout')
config.add_route('/api/users/register', '/api/users/register')
config.add_route('/api/users/legal', '/api/users/legal')
config.add_route('/api/users', '/api/users')
config.add_route('/api/users/{id}', '/api/users/{id}')
config.add_route('/api/partner_levels', '/api/partner_levels')
config.add_route('/api/partner_levels/{id}', '/api/partner_levels/{id}')
config.add_route('/api/partners', '/api/partners')
config.add_route('/api/partners/{id}', '/api/partners')
config.add_route('/api/rides', '/api/rides')
config.add_route('/api/rides/{id}', '/api/rides/{id}')
config.add_route('/api/ride_sponsors', '/api/ride_sponsors')
config.add_route('/api/ride_sponsors/{id}', '/api/ride_sponsors/{id}')
config.add_route('/api/checkins', '/api/checkins')
config.add_route('/api/checkins/{id}', '/api/checksin/{id}')
config.scan()
return config.make_wsgi_app()
示例14: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# email to send forms
settings['from'] = '[email protected]'
settings['to'] = '[email protected]'
# settings['session.secret'] = 'u3wawf7jmvypAz8hpE8Yfu7J4fGZzbkg'
# settings['session.key'] = 'rubyrate'
# settings['session.auto'] = True
# settings['session.cookie_expires'] = True
# settings['session.type'] = 'file'
#
# settings['session.data_dir'] = here + '/data/sessions/data'
# settings['session.lock_dir'] = here + '/data/sessions/lock'
settings['mako.directories'] = 'rubyrate:templates'
settings['mako.module_directory'] = 'rubyrate:data/templates'
settings['mako.imports'] = ['from webhelpers.html import escape',
'from webhelpers.html import literal']
settings['mako.default_filters'] = ['escape']
# adding the renderer to my own version of form
deform_templates = resource_filename('deform', 'templates')
search_path = (here + '/templates/deform') #, deform_templates
#settings['deform.renderer'] = ZPTRendererFactory(search_path)
settings['deform.searchpath'] = here + '/templates/deform'
Form.set_zpt_renderer(search_path)
authn_policy = AuthTktAuthenticationPolicy(
secret='u3wawf7jmvypAz8hpE8Yfu7J4fGZzbkg',
callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(root_factory=appmaker,
settings=settings,
authentication_policy=authn_policy,
authorization_policy=authz_policy)
config.set_session_factory(session_factory_from_settings(settings))
# Mongo Setup
conn = pymongo.Connection('mongodb://localhost/')
config.registry.settings['db_conn'] = conn
config.include('pyramid_mailer')
config.add_static_view('static', 'rubyrate:static', cache_max_age=315360000)
config.scan('rubyrate')
config.set_request_factory(RequestWithUserAttribute)
return config.make_wsgi_app()
示例15: make_webapp
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_request_factory [as 别名]
def make_webapp(database_uri, default_timezone=None):
init_db(database_uri)
config = Configurator(root_factory=Root)
RequestWithTimezone._default_timezone = default_timezone
config.set_request_factory(RequestWithTimezone)
config.add_settings({"mako.directories": "zilch:templates/", "mako.default_filters": "h"})
config.add_static_view("stylesheets", "zilch:static/stylesheets")
config.add_static_view("images", "zilch:static/images")
config.add_static_view("javascripts", "zilch:static/javascripts")
config.scan("zilch.web")
app = config.make_wsgi_app()
return app