本文整理汇总了Python中pyramid.config.Configurator.set_default_permission方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.set_default_permission方法的具体用法?Python Configurator.set_default_permission怎么用?Python Configurator.set_default_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.set_default_permission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
# Auth system
secret_key = settings.get('secret.key', 'secretkey')
authentication_policy = AuthTktAuthenticationPolicy(secret_key, hashalg='sha512')
authorization_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, authentication_policy=authentication_policy, authorization_policy=authorization_policy)
config.set_default_permission('view')
# Including packages
config.include('pyramid_jinja2')
config.include('.models')
config.include('.views')
# Configuring jinja2
config.add_jinja2_search_path('jesusanaya_blog:templates/', name='.html')
config.add_jinja2_renderer('.html', settings_prefix='jinja2.')
config.add_static_view(name='static', path='jesusanaya_blog:static', cache_max_age=3600)
config.add_request_method(request_static_method, 'static')
config.scan()
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['sqlalchemy.url'] = settings['cn.dialect'] + quote_plus(settings['sqlalchemy.url'])
engine = engine_from_config(settings, 'sqlalchemy.')
dbConfig['url'] = settings['sqlalchemy.url']
DBSession.configure(bind=engine)
Base.metadata.bind = engine
Base.metadata.create_all(engine)
Base.metadata.reflect(views=True, extend_existing=False)
config = Configurator(settings=settings)
# Add renderer for datetime objects
json_renderer = JSON()
json_renderer.add_adapter(datetime, datetime_adapter)
json_renderer.add_adapter(Decimal, decimal_adapter)
json_renderer.add_adapter(bytes, bytes_adapter)
config.add_renderer('json', json_renderer)
# Set up authentication and authorization
includeme(config)
# config.set_root_factory(SecurityRoot)
# config.set_request_factory(request_factory)
config.add_subscriber(add_cors_headers_response_callback, NewRequest)
# Set the default permission level to 'read'
config.set_default_permission('read')
config.include('pyramid_tm')
add_routes(config)
config.scan()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [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
authentication = AuthTktAuthenticationPolicy('secretstring')
authorization = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
request_factory=MyRequest,
root_factory=RootFactory
)
config.set_default_permission('view')
config.set_authentication_policy(authentication)
config.set_authorization_policy(authorization)
config.add_forbidden_view(view=logout_view)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('result', '/result')
config.add_route('register', '/register')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('history', '/history')
config.add_route('history_popular', '/history_popular')
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [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
authn_policy = AuthTktAuthenticationPolicy('sosecret')
authz_policy = ACLAuthorizationPolicy()
config = Configurator(
settings=settings,
root_factory=Root,
)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.set_default_permission('view')
config.add_forbidden_view(view=logout)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_request_method(get_user, 'user', reify=True)
config.add_route('home', '/')
config.add_route('search_result', '/search_result')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('register', '/register')
config.add_route('history', '/history')
config.add_route('history_refresh', '/history_refresh')
config.add_route('top', '/top')
config.scan()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet', timeout=86400)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, session_factory=my_session_factory, root_factory=AuthRoot)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.include('pyramid_jinja2')
config.include("cornice")
config.include('velruse.providers.github')
config.add_renderer('.html', factory='pyramid_jinja2.renderer_factory')
config.add_jinja2_search_path("verse:templates")
config.add_static_view('static', 'static', cache_max_age=3600)
config.set_default_permission('view')
config.add_github_login_from_settings(prefix='velruse.github.')
setup_urls(config)
config.scan('verse.views')
config.scan('verse.setup_views')
config.scan('verse.account_views')
return config.make_wsgi_app()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
if settings.get("heroku"):
settings = heroku_settings(settings)
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings, root_factory=Root)
config.include("pyramid_persona")
authn_policy = AuthTktAuthenticationPolicy(
settings["persona.secret"], hashalg="sha512", max_age=60 * 60 * 24 * 30
) # 1 month
config.set_authentication_policy(authn_policy)
session_factory = UnencryptedCookieSessionFactoryConfig(settings["persona.secret"], timeout=60 * 60 * 24)
config.set_session_factory(session_factory)
utils.cache.configure_from_config(settings, "cache.")
config.include("augias.utils.flash")
config.add_request_method(get_user, "user", reify=True)
config.add_subscriber(add_global, BeforeRender)
config.set_default_permission("access")
config.add_static_view("static", "static", cache_max_age=3600)
config.scan(".views")
return config.make_wsgi_app()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings["sqlalchemy.url"] = postgres_url()
engine = engine_from_config(settings, "sqlalchemy.")
db.DBSession.configure(bind=engine)
db.Base.metadata.bind = engine
config = Configurator(settings=settings)
config.set_root_factory(RootFactory)
config.set_default_permission("all")
config.include("pyramid_jwtauth")
config.add_route("home", "/")
config.add_route("states", "/states/")
config.add_route("auth.register", "/auth/register/")
config.add_route("auth.login", "/auth/login/")
config.add_route("auth.logout", "/auth/logout/")
config.add_route("girias", "/girias/")
config.scan()
return config.make_wsgi_app()
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [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, root_factory='flog.models.rootfactory.RootFactory')
config.set_authentication_policy(AuthTktAuthenticationPolicy('flogkrit', hashalg='sha512'))
config.set_authorization_policy(ACLAuthorizationPolicy())
config.set_default_permission('edit')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('shift', '/shift/{date}')
config.add_route('show', '/show/{id}')
config.add_route('about', '/about')
config.add_route('admin', '/admin/')
config.add_route('settings', '/admin/settings')
config.add_route('create', '/admin/create/{date}')
config.add_route('delete', '/admin/delete/{id}')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.scan()
return config.make_wsgi_app()
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
authentication_policy = AuthTktAuthenticationPolicy('secretkey123456')
authorization_policy = FakeAuthorizationPolicy()
config = Configurator(
root_factory=AppRoot,
settings=settings,
authentication_policy=authentication_policy,
authorization_policy=authorization_policy
)
config.set_default_permission('view')
# To configure the slash-appending not found view in your application, change the application’s startup configuration, adding the following stanza
# config.add_view(context='pyramid.exceptions.NotFound', view='pyramid.view.append_slash_notfound_view')
# config.add_view('starter.views.my_view',
# context='starter:resources.Root',
# renderer='starter:templates/mytemplate.pt')
config.add_static_view('static', 'starter:static', cache_max_age=3600)
# Configurator.scan() should be called to activate subscribers... and @view_configs
config.scan()
return config.make_wsgi_app()
示例10: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
prepare_database(settings)
authn_policy = AuthTktAuthenticationPolicy(
'sikret;)', callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings,
root_factory=RootFactory)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.set_default_permission('registered')
config.include('pyramid_jinja2')
config.include("pyramid_beaker")
set_cache_regions_from_settings(settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('main', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('engine.ajax', '/engine.ajax')
config.scan()
return config.make_wsgi_app()
示例11: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
authn_policy = AuthTktAuthenticationPolicy(secret = settings['auth_secret']
, callback = security.auth.groupfinder
, cookie_name = settings['auth_cookie_name']
, secure = False #default. I'd like to make this true
, include_ip = True #not default. What're the implications?
, timeout = int(settings['auth_timeout'])
, reissue_time = int(settings['auth_reissue_time'])
, max_age = None #default...what does this do?
, http_only = True #not default..no reason to access the cookie from JS, but not all browsers honor this
, wild_domain = True #default...what does this do?
, debug = ['auth_debug']
#, hashalg = ['auth_hashalg']
)
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, root_factory='pim.security.root_factory.RootFactory')
config.include('pyramid_chameleon')
##add renderers from json.py
config.add_renderer('json', api.json_adapters.json_renderer)
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.set_default_permission('access')
api.financials.models.DBSession.configure(bind=engine)
api.financials.models.Base.metadata.bind = engine
api.diary.models.DBSession.configure(bind=engine)
api.diary.models.Base.metadata.bind = engine
#config.add_static_view('static', 'static', cache_max_age=3600)
#for the main entry point to the SPA
config.add_route('app', '/')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('cash_accounts', 'api/financials/cash-accounts')
config.add_route('spending_items', 'api/financials/spending')
config.add_route('spending_item', 'api/financials/spending/{id}')
config.add_route('diary_entries', 'api/diary/entries')
config.add_route('diary_entry', 'api/diary/entries/{id}')
#this sets up the ui folder to be served from the root, so things like /common/...js work
config.add_static_view('', 'ui', permission='access', cache_max_age = 0)
config.scan()
return config.make_wsgi_app()
示例12: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [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)
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.set_request_factory(request_factory) # REMOVE IT
config.add_static_view('static', 'static')
config.add_static_view('attachment',os.path.join(here, 'static/attachments'))
config.add_static_view('css',os.path.join(here, 'static/css'))
config.add_static_view('js',os.path.join(here, 'static/js'))
config.include('pyramid_chameleon')
""" Routes Here """
config.add_route('home', '/')
config.add_route('about', '/about')
config.add_route('help', '/help')
config.add_route('profile', '/profile')
config.add_route('training', '/training')
config.add_route('register', '/register')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('paragraphs','/paragraphs')
config.add_route('userParagraphs','/user/paragraphs')
config.add_route('userParagraphUpdate','/user/paragraphs/update')
config.add_route('getAllTrainedUsers','/get_all_trained_users')
config.add_route('getUsersTrainedWith','/get_users_trained_with')
config.add_route('getConvertedSpeeches','/get_converted_speeches')
config.add_route('trainWith','/train_with')
config.add_route('convertVoice','/convert_voice')
config.scan()
return config.make_wsgi_app()
示例13: make_app
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def make_app(global_config, **settings):
"""Return the WSGI application."""
nginx_upload_progress = settings.get(
'poulda.nginx_upload_progress', 'false').lower() == 'true'
if not nginx_upload_progress:
from poulda.models import initialize_db
initialize_db(settings['poulda.db_url'])
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
# Authentication and authorization policies
auth_policy = AuthTktAuthenticationPolicy(settings['poulda.secret'])
config.set_authentication_policy(auth_policy)
authz_policy = AuthorizationPolicy()
config.set_authorization_policy(authz_policy)
# Views
config.set_default_permission(PERMISSION_UPLOAD)
config.add_static_view('static', 'static')
config.add_route('home', '/')
config.add_view('poulda.views.home',
route_name='home',
permission=NO_PERMISSION_REQUIRED)
config.add_route('upload_form', '/upload', request_method='GET')
config.add_view('poulda.views.upload_form', route_name='upload_form')
config.add_route('upload', '/upload', request_method='POST')
if nginx_upload_progress:
upload_view = 'poulda.views.upload_with_nginx_upload_progress'
else:
upload_view = 'poulda.views.upload'
config.add_view(upload_view, route_name='upload')
if not nginx_upload_progress:
# We need this view only if Nginx Upload Progress has been
# disabled.
config.add_route('progress', '/progress')
config.add_view('poulda.views.progress', route_name='progress',
renderer='json')
config.add_route('success', '/success')
config.add_view('poulda.views.success', route_name='success')
config.add_route('login', '/login', request_method='POST')
config.add_view('poulda.views.login', route_name='login',
permission=NO_PERMISSION_REQUIRED)
config.add_route('logout', '/logout')
config.add_view('poulda.views.logout', route_name='logout')
config.add_view('poulda.views.forbidden', context=HTTPForbidden,
permission=NO_PERMISSION_REQUIRED)
# Internationalization
config.add_translation_dirs('poulda:locale')
config.set_locale_negotiator('poulda.i18n.locale_negotiator')
return config.make_wsgi_app()
示例14: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('pyramid_sqlalchemy')
config.include('cornice')
config.set_authentication_policy(BasicAuthAuthenticationPolicy(check=check))
config.set_authorization_policy(ACLAuthorizationPolicy())
config.set_default_permission(Authenticated)
config.add_request_method(get_user, 'user', reify=True)
config.include('.models')
config.scan()
return config.make_wsgi_app()
示例15: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import set_default_permission [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)
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", "static")
config.add_static_view("attachment", os.path.join(here, "static/attachments"))
config.add_static_view("css", os.path.join(here, "static/css"))
config.add_static_view("js", os.path.join(here, "static/js"))
config.include("pyramid_chameleon")
""" Routes Here """
config.add_route("home", "/")
config.add_route("profile", "/profile")
config.add_route("about", "/about")
config.add_route("registerStudent", "/register_student")
config.add_route("login", "/login")
config.add_route("logout", "/logout")
config.add_route("instituteGetAll", "/institute_get_all")
config.add_route("instituteGet", "/institute_get/{id}")
config.add_route("studentCourses", "/student_courses")
config.add_route("courseGetAll", "/course_get_all")
config.add_route("courseInstituteGetAll", "/course_institute_get_all")
config.add_route("courseFaculty", "/course_faculty/{course_id}")
config.add_route("courseResource", "/course_resource/{course_id}")
config.add_route("courseAssignment", "/course_assignment/{course_id}")
config.add_route("courseMarks", "/course_marks/{course_id}")
config.add_route("courseQuiz", "/course_quiz/{course_id}")
config.add_route("courseGet", "/course_get/{id}")
config.add_route("courseRegister", "/course_register")
config.scan()
return config.make_wsgi_app()