本文整理汇总了Python中pyramid.config.Configurator.ptah_init_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.ptah_init_settings方法的具体用法?Python Configurator.ptah_init_settings怎么用?Python Configurator.ptah_init_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.ptah_init_settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup."""
config = Configurator(settings=settings, session_factory=session_factory, authentication_policy=auth_policy)
config.add_static_view("ptah_models", "ptah_models:static")
# we love them routes
config.add_route("root", "/")
config.add_route("contact-us", "/contact-us.html")
config.add_route("edit-links", "/links/{id}/edit", factory=models.factory, use_global_views=True)
config.add_route("add-link", "/links/add.html")
config.include("ptah")
config.scan()
# init ptah settings
config.ptah_init_settings()
# init sqlalchemy
config.ptah_init_sql()
# init ptah manage
config.ptah_init_manage(managers=["*"], disable_modules=["rest", "introspect", "apps", "permissions", "settings"])
config.commit()
# Need to commit links to database manually.
import transaction
transaction.commit()
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup.
"""
config = Configurator(settings=settings)
config.include('pyramid_mailer')
config.include('ptahcrowd')
config.include('ptahcms')
config.include('devapp')
# init ptah settings
config.ptah_init_settings()
# init ptah sqlalchemy
config.ptah_init_sql()
# enable rest api
config.ptah_init_rest()
# enable ptah manage
config.ptah_init_manage()
# enable ptah manage
config.ptah_populate()
# set ptah mailer
from pyramid_mailer.interfaces import IMailer
mailer = config.registry.queryUtility(IMailer)
config.ptah_init_mailer(mailer.direct_delivery)
# We are not in a web request; we need to manually commit.
transaction.commit()
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup."""
config = Configurator(settings=settings,
session_factory = session_factory,
authentication_policy = auth_policy)
# init ptah settings
config.ptah_init_settings()
# init sqlalchemy engine
config.ptah_init_sql()
# configure ptah manage
config.ptah_init_manage(
managers = ['*'],
disable_modules = ['rest', 'introspect', 'apps', 'permissions'])
# we love them routes
config.add_route('root', '/')
config.add_route('login', '/login.html')
config.add_route('logout', '/logout.html')
# static assets
config.add_static_view('ptah_simpleauth', 'ptah_simpleauth:static')
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup.
"""
config = Configurator(root_factory=APP_FACTORY, settings=settings)
# static assets
config.add_static_view('ptah_minicms', 'ptah_minicms:static')
config.scan()
# init sqlalchemy engine
config.ptah_init_sql()
# init ptah settings
config.ptah_init_settings()
# enable rest api
config.ptah_init_rest()
# enable ptah manage
config.ptah_init_manage()
# populate database
config.ptah_populate()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(init=True):
import gevent.monkey
gevent.monkey.patch_all()
args = BackendCommand.parser.parse_args()
# logging config
def fileConfig(f, defaults):
from logging.config import fileConfig
return fileConfig(f, defaults, disable_existing_loggers = False)
paster.setup_logging(args.config.split('#', 1)[0], fileConfig)
# read settings
parser = configparser.SafeConfigParser()
parser.read((args.config,))
settings = parser.items(configparser.DEFAULTSECT, vars={'here': './'})
# run configuration
config = Configurator(settings=settings)
config.include('ptah')
config.include('smxq')
# ptah
config.ptah_init_sql()
config.ptah_init_settings()
config.commit()
# run command
cmd = BackendCommand(args, config.registry, config)
cmd.run()
ptah.shutdown()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup."""
config = Configurator(settings=settings,
session_factory = session_factory,
authentication_policy = auth_policy)
# config.commit()
# config.begin()
# init ptah settings
config.ptah_init_settings()
# init sqlalchemy engine
config.ptah_init_sql()
# configure ptah manage
config.ptah_init_manage(
managers = ['*'],
disable_modules = ['rest', 'introspect', 'apps', 'permissions'])
# we love them routes
config.add_route('root', '/')
config.add_route('contact-us', '/contact-us.html')
config.add_route('edit-objects', '/objects/{id}/edit',
factory=models.rackobject.factory, use_global_views=True)
config.add_route('add-object', '/objects/add.html')
config.add_route('login', '/login.html')
config.add_route('logout', '/logout.html')
# static assets
config.add_static_view('rackptahbles', 'rackptahbles:static')
config.scan()
# create sql tables
Base = ptah.get_base()
Base.metadata.create_all()
transaction.commit()
# populate database
config.commit()
config.begin()
Session = ptah.get_session()
# admin user
user = Session.query(User).first()
if user is None:
user = User('Admin', 'admin', '[email protected]', '12345')
Session.add(user)
#bootstrap data here, removed rackptahbles link population
# Need to commit bootstrap data to database manually.
transaction.commit()
return config.make_wsgi_app()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" Function which returns a configured Pyramid/Ptah WSIG Application """
# Construct a db connection URL from 30Loops environment variables
# pattern is postgresql+psycopg2://scott:[email protected]/mydatabase
env = None
try:
f = open('/app/conf/environment.json')
env = json.load(f)
db_user = env["DB_USER"]
db_name = env["DB_NAME"]
db_host = env["DB_HOST"]
db_pass = env["DB_PASSWORD"]
db_url = "postgresql+psycopg2://"+db_user+":"+db_pass+"@"+db_host+"/"+dbname
# Override the SQLAlchemy url from settings.ini
settings['sqlalchemy.url']=db_url
except:
pass
# Info: This is how Pyramid is configured.
config = Configurator(settings=settings,
session_factory = session_factory,
authentication_policy = auth_policy)
# Info: This includes packages which have Pyramid configuration
config.include('ptah')
config.commit()
# Refer: Ptah: _Initialization_
config.ptah_init_settings()
# Refer: Ptah: _Initialization_
config.ptah_init_sql()
# enable ptah management
config.ptah_init_manage(managers=('*',))
# populate database
config.ptah_populate()
# Refer: Pyramid's _URL Dispatch_
config.add_route('home', '/')
# static assets
config.add_static_view('_urbsly', 'urbsly:static')
# Refer: Pyramid's _Configuration Decorations and Code Scanning_
config.scan()
return config.make_wsgi_app()
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" Function which returns a configured Pyramid/Ptah WSIG Application """
# Info: This is how Pyramid is configured.
durl = os.environ.get("DATABASE_URL") #heroku
if durl:
settings['sqlalchemy.url']=durl
else:
logger.info('Did not find DATABASE_URL! You must issue, '
'$ heroku addons:add shared-database')
config = Configurator(settings=settings,
session_factory = session_factory,
authentication_policy = auth_policy)
# Info: This includes packages which have Pyramid configuration
config.include('ptah')
# Refer: Ptah: _Initialization_
config.ptah_init_settings()
# Refer: Ptah: _Initialization_
config.ptah_init_sql()
# enable ptah management
config.ptah_init_manage(managers=('admin',))
# populate database
config.ptah_populate()
# Refer: Pyramid's _URL Dispatch_
config.add_route('home', '/')
config.add_route('home2', '/home2')
# static assets
config.add_static_view('_herokuapp', 'herokuapp:static')
# js protocols
config.include('herokuapp.protocols')
# add role
Admin = ptah.Role('admin', 'Admin')
Manager = ptah.Role('manager', 'Manager')
# Refer: Pyramid's _Configuration Decorations and Code Scanning_
config.scan()
return config.make_wsgi_app()
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
config = Configurator(settings=settings,
root_factory = models.blog_factory,
session_factory = session_factory,
authentication_policy = auth_policy)
config.add_static_view('ptahto', 'ptahto:static')
config.add_route('blog', '/')
config.add_route('config', '/config.html')
config.add_route('dashboard', '/dashboard.html')
config.add_route('about', '/about.html')
config.add_route('rss', '/rss')
config.add_route('atom', '/atom')
config.add_route('archive', '/posts')
config.add_route('add-post', '/posts/add.html')
config.add_route('view-post', '/posts/{id}',
factory=models.post_factory, use_global_views=True)
config.add_route('edit-post', '/posts/{id}/edit.html',
factory=models.post_factory, use_global_views=True)
config.add_route('categories', '/categories')
config.add_route('add-category', '/categories/add.html')
config.add_route('view-category', '/categories/{id}',
factory=models.category_factory, use_global_views=True)
config.add_route('edit-category', '/categories/{id}/edit.html',
factory=models.category_factory, use_global_views=True)
config.add_route('rss-category', '/categories/{id}/rss',
factory=models.category_factory, use_global_views=True)
config.add_route('atom-category', '/categories/{id}/atom',
factory=models.category_factory, use_global_views=True)
config.include('ptah')
config.scan()
config.ptah_init_settings()
config.ptah_init_sql()
config.ptah_init_manage(
managers = ['*'],
disable_modules = ['rest', 'introspect', 'apps', 'permissions', 'settings'])
config.commit()
import transaction
transaction.commit()
return config.make_wsgi_app()
示例10: test_init_ptah_init
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def test_init_ptah_init(self):
config = Configurator()
data = [False, False]
def settings_initialized_handler(ev):
data[1] = True
sm = config.registry
sm.registerHandler(
settings_initialized_handler,
(ptah.events.SettingsInitialized,))
config.include('ptah')
config.ptah_init_settings()
config.commit()
self.assertTrue(data[1])
示例11: initializeConfig
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def initializeConfig(settings, filepath=None, nodb=False):
if filepath is None:
filepath = CONFIGFILE
settings['include'] = filepath
print settings
cfg = Configurator(settings=settings)
cfg.include('ptah')
cfg.include('ploud.utils')
cfg.commit()
cfg.begin()
cfg.ptah_init_settings()
cfg.commit()
global PYRAMID_CONFIG
PYRAMID_CONFIG = cfg
示例12: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" Function which returns a configured Pyramid/Ptah WSIG Application """
# Info: This is how Pyramid is configured.
# Originally for Heroku, needs to be modified for 30Loops
#durl = os.environ.get("DATABASE_URL")
#if durl:
# settings['sqlalchemy.url']=durl
config = Configurator(settings=settings,
session_factory = session_factory,
authentication_policy = auth_policy)
# Info: This includes packages which have Pyramid configuration
config.include('ptah')
config.commit()
# Refer: Ptah: _Initialization_
config.ptah_init_settings()
# Refer: Ptah: _Initialization_
config.ptah_init_sql()
# enable ptah management
config.ptah_init_manage(managers=('*',))
# populate database
config.ptah_populate()
# Refer: Pyramid's _URL Dispatch_
config.add_route('home', '/')
# static assets
config.add_static_view('_urbsly', 'urbsly:static')
# Refer: Pyramid's _Configuration Decorations and Code Scanning_
config.scan()
return config.make_wsgi_app()
示例13: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup."""
config = Configurator(settings=settings,
session_factory = session_factory)
config.ptah_init_settings()
config.ptah_init_sql()
config.ptah_init_manage(managers = ['*'])
config.ptah_populate()
# enable jca
config.register_jca_sm()
# internal chat
config.register_jca_component(
'chat', 'ptah_chat:jca/', protocol = ChatProtocol)
# we love them routes
config.add_route('root', '/')
config.scan()
return config.make_wsgi_app()
示例14: test_init_ptah_init_settings_exception
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def test_init_ptah_init_settings_exception(self):
config = Configurator(autocommit = True)
class CustomException(Exception):
pass
def initialized_handler(ev):
raise CustomException()
sm = config.registry
sm.registerHandler(
initialized_handler,
(ptah.events.SettingsInitialized,))
config.include('ptah')
err = None
try:
config.ptah_init_settings()
except Exception as e:
err = e
self.assertIsInstance(err, ptah.config.StopException)
self.assertIsInstance(err.exc, CustomException)
示例15: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_settings [as 别名]
def main(global_config, **settings):
""" This is your application startup.
"""
config = Configurator(root_factory=APP_FACTORY, settings=settings)
# mustache templates
config.add_mustache_bundle('ptah_ws', 'ptah_ws:jcatemplates/')
# jca module
config.register_amd_module('settings', 'ptah_ws:static/settings.js')
# static assets
config.add_static_view('ptah_ws', 'ptah_ws:static')
config.scan()
# init sqlalchemy engine
config.ptah_init_sql()
# init ptah settings
config.ptah_init_settings()
# enable rest api
config.ptah_init_rest()
# enable ptah manage
config.ptah_init_manage()
# populate database
config.ptah_populate()
# init sqlalchemy session
import ptah_ws
engine = sa.engine_from_config(settings, 'sqlalchemy.')
ptah_ws._Session = sa.orm.sessionmaker(bind=engine)
return config.make_wsgi_app()