本文整理汇总了Python中pyramid.config.Configurator.add_twitter_login_from_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.add_twitter_login_from_settings方法的具体用法?Python Configurator.add_twitter_login_from_settings怎么用?Python Configurator.add_twitter_login_from_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.add_twitter_login_from_settings方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [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()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
session_factory = UnencryptedCookieSessionFactoryConfig(settings["cookie.secret"])
providers = settings.get("login_providers", "")
providers = filter(None, [p.strip() for line in providers.splitlines() for p in line.split(", ")])
settings["login_providers"] = providers
config = Configurator(settings=settings, session_factory=session_factory)
config.add_static_view("static", "static", cache_max_age=3600)
if "facebook" in providers:
config.include("velruse.providers.facebook")
config.add_facebook_login_from_settings(prefix="facebook.")
if "twitter" in providers:
config.include("velruse.providers.twitter")
config.add_twitter_login_from_settings(prefix="twitter.")
config.add_route("home", "/")
config.add_route("register", "register")
# config.add_route("facebook_login", "/facebook/login")
# config.add_route("twitter_login", "/twitter/login")
config.scan()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application."""
# velruse requires session support
session_factory = UnencryptedCookieSessionFactoryConfig(
settings['session.secret'],
)
# determine which providers we want to configure
providers = settings.get('login_providers', '')
providers = filter(None, [p.strip()
for line in providers.splitlines()
for p in line.split(', ')])
settings['login_providers'] = providers
if not any(providers):
log.warn('no login providers configured, double check your ini '
'file and add a few')
config = Configurator(settings=settings)
config.set_session_factory(session_factory)
config.add_static_view('static', 'static', cache_max_age=3600)
if 'facebook' in providers:
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='facebook.')
if 'github' in providers:
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='github.')
if 'twitter' in providers:
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='twitter.')
if 'live' in providers:
config.include('velruse.providers.live')
config.add_live_login_from_settings(prefix='live.')
if 'bitbucket' in providers:
config.include('velruse.providers.bitbucket')
config.add_bitbucket_login_from_settings(prefix='bitbucket.')
if 'google' in providers:
config.include('velruse.providers.google')
config.add_google_login(
realm=settings['google.realm'],
consumer_key=settings['google.consumer_key'],
consumer_secret=settings['google.consumer_secret'],
)
if 'yahoo' in providers:
config.include('velruse.providers.yahoo')
config.add_yahoo_login(
realm=settings['yahoo.realm'],
consumer_key=settings['yahoo.consumer_key'],
consumer_secret=settings['yahoo.consumer_secret'],
)
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [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
settings['mako.directories'] = os.path.join(here,'templates')
session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
config = Configurator(settings=settings,root_factory='.models.RootFactory', session_factory=session_factory)
"""Velruse 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.')
authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.set_default_permission(Authenticated)
config.add_static_view('static', 'hallwala:static')
config.add_static_view('attachment',os.path.join(here, 'static/attachments'))
config.add_static_view('assets',os.path.join(here, 'static/assets'))
config.add_static_view('css',os.path.join(here, 'static/css'))
config.add_static_view('images',os.path.join(here, 'static/images'))
config.add_static_view('js',os.path.join(here, 'static/js'))
config.include('pyramid_chameleon')
"""Routes Here"""
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('loginpage', '/login_page')
config.add_route('agent', '/agent')
"""Static Pages"""
config.add_route('howItWorks','/how_it_works')
config.add_route('contact','/contact')
config.add_route('aboutUs','/about_us')
config.add_route('termsAndConditions','/terms_and_conditions')
config.add_route('vision','/vision')
config.add_route('team','/team')
"""Events API"""
config.add_route('eventAdd','/event_add')
config.add_route('eventGetAll','/event_get_all')
config.add_route('eventGetType','/event_get_type/{type}')
config.add_route('eventGet','/event_get/{event_id}')
config.add_route('eventDelete','/event_delete/{event_id}')
config.scan()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [as 别名]
def main(global_config, **settings):
""" This function returns a WSGI application.
"""
# velruse requires session support
#session_factory = UnencryptedCookieSessionFactoryConfig(
# settings['session.secret'],
#)
providers = settings.get('login_providers', '')
providers = filter(None, [p.strip()
for line in providers.splitlines()
for p in line.split(', ')])
settings['login_providers'] = providers
#config = Configurator(settings=settings, root_factory=Root)
session_factory = session_factory_from_settings(settings)
config = Configurator(
settings=settings,
session_factory=session_factory
)
#config = Configurator(settings=settings)
# Configure Beaker sessions and caching.
config.include("pyramid_beaker")
# config.add_view('login.views.my_view',
# context='login:resources.Root',
# renderer='login:templates/mytemplate.pt')
#config.set_session_factory(session_factory)
config.add_static_view('static', 'static', cache_max_age=3600)
if 'facebook' in providers:
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='facebook.')
if 'github' in providers:
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='github.')
if 'twitter' in providers:
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='twitter.')
if 'live' in providers:
config.include('velruse.providers.live')
config.add_live_login_from_settings(prefix='live.')
if 'bitbucket' in providers:
config.include('velruse.providers.bitbucket')
config.add_bitbucket_login_from_settings(prefix='bitbucket.')
if 'google' in providers:
config.include('velruse.providers.google')
config.add_google_login(
realm=settings['google.realm'],
consumer_key=settings['google.consumer_key'],
consumer_secret=settings['google.consumer_secret'],
)
if 'yahoo' in providers:
config.include('velruse.providers.yahoo')
config.add_yahoo_login(
realm=settings['yahoo.realm'],
consumer_key=settings['yahoo.consumer_key'],
consumer_secret=settings['yahoo.consumer_secret'],
)
config.add_route('home','/')
config.add_view(index, route_name='home',
renderer="neuron:templates/index.pt")
config.add_route('resume_v','/resume_view')
config.add_view(resume_read,route_name='resume_v',renderer="neuron:templates/resume_display.mako")
config.add_route('friend','/friend')
config.add_view(friend,route_name='friend',renderer="neuron:templates/friend.mako")
config.add_route('resume_en','/resume_entered')
config.add_view(resume_write,route_name='resume_en',renderer="neuron:templates/resume_view.mako")
config.add_route('error','/error')
config.add_view(error,route_name='error',renderer="neuron:templates/error.mako")
config.add_route('social_first','/profile_details')
config.add_view(social,route_name='social_first',renderer="neuron:templates/register.pt")
config.add_route('social','/home')
config.add_view(social,route_name='social',renderer="neuron:templates/home.pt")
config.add_route('resume_ed','/resume_edit')
config.add_view(resume_read,route_name='resume_ed',renderer="neuron:templates/resume_view.mako")
config.add_route('delete_edu','/delete_education')
config.add_view(resume_delete,route_name='delete_edu',renderer="neuron:templates/resume_view.mako")
config.add_route('auth','/auth')
config.add_view(authenticate, route_name='auth',renderer="neuron:templates/home.pt")
config.add_route('sign-up','/signup')
config.add_view(signup, route_name="sign-up", renderer="neuron:templates/sign_up.pt")
config.add_route('register-user','/register')
config.add_view(register_user, route_name="register-user", renderer="neuron:templates/register.pt")
#.........这里部分代码省略.........
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [as 别名]
def main(global_config, **settings):
"Returns the Pyramid WSGI application"
# Ensure we're not using production.ini verbatim
for key in (
'site.store',
'session.secret',
'login.google.consumer_key',
'login.google.consumer_secret',
'login.facebook.consumer_key',
'login.facebook.consumer_secret',
'login.twitter.consumer_key',
'login.twitter.consumer_secret',
'login.github.consumer_key',
'login.github.consumer_secret',
):
if settings.get(key) == 'CHANGEME':
raise ValueError('You must specify a new value for %s' % key)
# Ensure path is configured appropriately
files_dir = os.path.normpath(os.path.expanduser(settings['site.files']))
licenses_dir = os.path.normpath(os.path.expanduser(settings['licenses.cache_dir']))
check_path(settings['site.files'])
check_path(settings['licenses.cache_dir'])
session_factory = session_factory_from_settings(settings)
mailer_factory = mailer_factory_from_settings(settings)
licenses_factory = licenses_factory_from_settings(settings)
engine = engine_from_config(settings, 'sqlalchemy.')
# Configure the database session; the session is deliberately separated
# from the model to enable us to bind it to an engine before importing
# the model which will then use the bound engine to reflect the database
from .db_session import DBSession
DBSession.configure(bind=engine, info={'site.files': files_dir})
from .security import RequestWithUser, group_finder
config = Configurator(
settings=settings,
session_factory=session_factory,
request_factory=RequestWithUser,
)
if settings.get('login.google.consumer_key'):
config.include('velruse.providers.google_oauth2')
config.add_google_oauth2_login_from_settings(prefix='login.google.')
if settings.get('login.facebook.consumer_key'):
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='login.facebook.')
if settings.get('login.twitter.consumer_key'):
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='login.twitter.')
if settings.get('login.github.consumer_key'):
config.include('velruse.providers.github')
config.add_github_login_from_settings(prefix='login.github.')
config.include('pyramid_chameleon')
# XXX Need some way of grabbing the authentication secret from config
authn_policy = AuthTktAuthenticationPolicy(
'secret', hashalg='sha512', callback=group_finder)
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.registry['mailer'] = mailer_factory
config.registry['licenses'] = licenses_factory
config.add_static_view('static', 'static', cache_max_age=3600)
from .views.comics import routes as comic_routes
from .views.admin import routes as admin_routes
from .security import (
RootContextFactory,
ComicContextFactory,
IssueContextFactory,
PageContextFactory,
)
for name, pattern in comic_routes() + admin_routes():
if '{page' in pattern:
factory = PageContextFactory
elif '{issue' in pattern:
factory = IssueContextFactory
elif '{comic' in pattern:
factory = ComicContextFactory
else:
factory = RootContextFactory
config.add_route(name, pattern, factory=factory)
config.scan()
return config.make_wsgi_app()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_twitter_login_from_settings [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
session_factory = session_factory_from_settings(settings)
from szcz.security import groupfinder
authentication_policy = SessionAuthenticationPolicy(callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings)
config.set_authentication_policy(authentication_policy)
config.set_authorization_policy(authorization_policy)
config.set_request_property('szcz.security.get_user', name='user', reify=True)
config.add_request_method('szcz.security.has_permission')
config.include('pyramid_fanstatic')
config.include('velruse.providers.google_oauth2')
config.add_google_oauth2_login_from_settings(prefix='google.')
config.include('velruse.providers.facebook')
config.add_facebook_login_from_settings(prefix='facebook.')
config.include('velruse.providers.twitter')
config.add_twitter_login_from_settings(prefix='twitter.')
config.include('pyramid_beaker')
config.include('deform_bootstrap')
config.include('js.deform_bootstrap')
config.include('pyramid_mailer')
config.include('pyramid_deform')
config.include('pyramid_zcml')
deform_templates = resource_filename('deform', 'templates')
deform_bootstrap_templates = resource_filename('deform_bootstrap', 'templates')
deform_szcz_templates = resource_filename('szcz', 'templates')
search_path = (deform_szcz_templates, deform_bootstrap_templates, deform_templates)
def translator(term):
return get_localizer(get_current_request()).translate(term)
Form.set_zpt_renderer(search_path, translator=translator)
config.add_route('favicon', '/favicon.ico')
config.add_route('home', '/')
config.add_route('proxyerror', '/proxyerror')
config.add_route('logout', '/logout')
config.add_route('userprofile', '/profile')
config.add_route('view_book', '/books/{id:\d+}')
config.add_route('my_books', '/books/only_mine')
config.add_route('list_books', '/books')
config.add_route('list_canons', '/canons')
config.add_route('view_canon', '/canons/{id:\d+}')
config.add_route('my_groups', '/groups/only_mine')
config.add_route('list_groups', '/groups')
config.add_route('add_group', '/groups/+')
config.add_route('join_group', '/groups/{id:\d+}/join', factory='szcz.groups.GroupContext')
config.add_route('logo_group', '/groups/{id:\d+}/logo_view', factory='szcz.groups.GroupContext')
config.add_route('wf_group', '/groups/{id:\d+}/change_state', factory='szcz.groups.GroupContext')
config.add_route('wf_groupmembership', '/groups/{id:\d+}/member/{email}/change_state', factory='szcz.groups.GroupContext')
config.add_route('view_group', '/groups/{id:\d+}', factory='szcz.groups.GroupContext')
config.add_route('edit_group', '/groups/{id:\d+}/edit', factory='szcz.groups.GroupContext')
config.add_route('add_book', '/groups/{id:\d+}/add_book', factory='szcz.groups.GroupContext')
config.add_route('print_activation_group', '/groups/{id:\d+}/print_activation', factory='szcz.groups.GroupContext')
config.add_route('manage_group_members', '/groups/{id:\d+}/manage_group_members', factory='szcz.groups.GroupContext')
config.add_static_view('deform_static', 'deform:static')
config.scan()
config.set_root_factory('szcz.views.Context')
config.set_session_factory(session_factory)
config.add_translation_dirs('deform:locale')
config.add_translation_dirs('colander:locale')
config.load_zcml('workflow.zcml')
return config.make_wsgi_app()