本文整理汇总了Python中pyramid.paster.get_appsettings方法的典型用法代码示例。如果您正苦于以下问题:Python paster.get_appsettings方法的具体用法?Python paster.get_appsettings怎么用?Python paster.get_appsettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.paster
的用法示例。
在下文中一共展示了paster.get_appsettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
from pyramid.paster import get_appsettings, setup_logging
from stalker import db
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
db.setup(settings)
db.init()
# create statuses
create_statuses_and_status_lists()
create_ticket_types()
示例2: main
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main(argv=sys.argv):
"""Initialize database, optionally with settings from config uri."""
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
if not settings.get('sqlalchemy.url'):
try:
settings['sqlalchemy.url'] = os.environ['MARS_DATABASE_URL']
except KeyError:
print('Required MARS_DATABASE_URL not set in global os environ.')
sys.exit()
try:
settings['nasa_api_key'] = os.environ['NASA_API_KEY']
except KeyError:
print('Required NASA_API_KEY not set in global os environment.')
sys.exit()
populate_rovers_cameras()
示例3: init_dummy_votes
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def init_dummy_votes(argv=sys.argv):
"""
Dummy votes
:param argv: standard argv
:return: None
"""
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
discussion_engine = get_dbas_db_configuration('discussion', settings)
DBDiscussionSession.configure(bind=discussion_engine)
DiscussionBase.metadata.create_all(discussion_engine)
with transaction.manager:
__setup_dummy_seen_by(DBDiscussionSession)
__setup_dummy_clicks(DBDiscussionSession)
示例4: main
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
dbUrl = settings['sqlalchemy.url']
if database_exists(dbUrl):
drop_database(dbUrl)
create_database(dbUrl)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
# DBSession.execute('DROP DATABASE IF EXISTS flashcarddb')
# DBSession.execute('CREATE DATABASE falshcarddb')
model = User(user_name='admin')
DBSession.add(model)
test_db()
示例5: engine_from_settings
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def engine_from_settings(config, full_config=False):
settings = get_appsettings(config, 'assembl')
if settings['sqlalchemy.url'].startswith('virtuoso:'):
db_schema = '.'.join((settings['db_schema'], settings['db_user']))
else:
db_schema = settings['db_schema']
set_config(settings, True)
session = None
if full_config:
env = bootstrap(config)
configure_zmq(settings['changes.socket'], False)
configure_model_watcher(env['registry'], 'assembl')
logging.config.fileConfig(config)
session = get_session_maker()
metadata = get_metadata()
else:
session = make_session_maker(zope_tr=True)
import assembl.models
from assembl.lib.sqla import class_registry
engine = configure_engine(settings, session_maker=session)
metadata = get_metadata()
metadata.bind = engine
session = sessionmaker(engine)()
return (metadata, session)
示例6: engine_from_settings
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def engine_from_settings(config, full_config=False):
settings = get_appsettings(config, 'assembl')
if settings['sqlalchemy.url'].startswith('virtuoso:'):
db_schema = '.'.join((settings['db_schema'], settings['db_user']))
else:
db_schema = settings['db_schema']
set_config(settings, True)
session = None
if full_config:
env = bootstrap(config)
configure_zmq(settings['changes.socket'], False)
configure_model_watcher(env['registry'], 'assembl')
logging.config.fileConfig(config)
else:
session = make_session_maker(zope_tr=True)
import assembl.models
from assembl.lib.sqla import class_registry
engine = configure_engine(settings, session_maker=session)
metadata = get_metadata()
metadata.bind = engine
session = sessionmaker(engine)()
return (metadata, session)
示例7: init_from_celery
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def init_from_celery(celery_app):
# A task is called through celery, so it may not have basic
# configuration setup. Go through that setup the first time.
global _settings
rootdir = dirname(dirname(dirname(realpath(__file__))))
settings_file = join(rootdir, 'local.ini')
if not exists(settings_file):
settings_file = join(rootdir, 'production.ini')
_settings = settings = get_appsettings(settings_file, 'assembl')
registry = getGlobalSiteManager()
registry.settings = settings
setup_raven(settings, settings_file)
set_config(settings)
configure_engine(settings, False)
configure(registry, celery_app.main)
from .threaded_model_watcher import ThreadDispatcher
threaded_watcher_class_name = settings.get(
'%s.threadedmodelwatcher' % (celery_app.main,),
"assembl.lib.model_watcher.ModelEventWatcherPrinter")
ThreadDispatcher.mw_class = resolver.resolve(threaded_watcher_class_name)
示例8: get_settings
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def get_settings(self):
"""Publice method to expose the application settings `dict`."""
settings = paster.get_appsettings(
os.path.join(
os.path.abspath(
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
),
'development.ini'
)
)
return settings
示例9: ini_settings
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def ini_settings(request):
"""Load INI settings from py.test command line."""
if not getattr(request.config.option, "ini", None):
raise RuntimeError("You need to give --ini test.ini command line option to py.test to find our test settings")
config_uri = os.path.abspath(request.config.option.ini)
setup_logging(config_uri)
config = get_appsettings(config_uri)
return config_uri, config
示例10: settings
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def settings():
"""
Default app settings (conf/test.ini).
:return: a list of loaded settings
"""
loaded_settings = get_appsettings('conf/test.ini')
if 'TEST_DATABASE_URL' in os.environ:
loaded_settings['sqlalchemy.url'] = normalize_database_url(os.environ['TEST_DATABASE_URL'])
return loaded_settings
示例11: setUp
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def setUp(self):
settings = get_appsettings('test.ini', name='main')
# sqlalchemy.url = sqlite:///%(here)s/example_ssl_minnow_test.sqlite
if False:
settings['sqlalchemy.url'] = "sqlite://"
app = main(global_config = None, **settings)
self.testapp = TestApp(app)
self._data_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_data')
示例12: app
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def app(request, global_environ, config_uri):
"""Create pretend app fixture of our main app."""
from mars_street_view import main
from webtest import TestApp
from pyramid.paster import get_appsettings
settings = get_appsettings(config_uri)
app = main({}, **settings)
test_app = TestApp(app)
def teardown():
pass
request.addfinalizer(teardown)
return test_app
示例13: main_discussion
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main_discussion(argv=sys.argv):
"""
Inits the main dummy discussion
:param argv: standard argv
:return: None
"""
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
discussion_engine = get_dbas_db_configuration('discussion', settings)
DBDiscussionSession.configure(bind=discussion_engine)
DiscussionBase.metadata.create_all(discussion_engine)
NewsBase.metadata.create_all(discussion_engine)
with transaction.manager:
users = __set_up_users(DBDiscussionSession)
lang1, lang2 = __set_up_language(DBDiscussionSession)
issue1, issue2, issue3, issue4, issue5, issue6, issue7 = __set_up_issue(DBDiscussionSession, lang1, lang2)
transaction.commit()
__set_up_settings(DBDiscussionSession, users)
main_author = DBDiscussionSession.query(User).filter_by(nickname=nick_of_anonymous_user).first()
__setup_discussion_database(DBDiscussionSession, main_author, issue1, issue2, issue4, issue5, issue7)
__add_reputation_and_delete_reason(DBDiscussionSession)
__setup_dummy_seen_by(DBDiscussionSession)
__setup_dummy_clicks(DBDiscussionSession)
__setup_review_dummy_database(DBDiscussionSession)
transaction.commit()
create_initial_issue_rss(get_global_url(), settings['pyramid.default_locale_name'])
示例14: main_field_test
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main_field_test(argv=sys.argv):
"""
Inits discussion for the field test about computer science studies
:param argv: standard argv
:return: None
"""
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
discussion_engine = get_dbas_db_configuration('discussion', settings)
DBDiscussionSession.configure(bind=discussion_engine)
DiscussionBase.metadata.create_all(discussion_engine)
with transaction.manager:
users = __set_up_users(DBDiscussionSession, include_dummy_users=False)
lang1, lang2 = __set_up_language(DBDiscussionSession)
issue6, issue1 = __set_up_issue(DBDiscussionSession, lang1, lang2, is_field_test=True)
__set_up_settings(DBDiscussionSession, users)
__setup_fieltest_discussion_database(DBDiscussionSession, issue6, issue1)
transaction.commit()
__add_reputation_and_delete_reason(DBDiscussionSession)
transaction.commit()
create_initial_issue_rss(get_global_url(), settings['pyramid.default_locale_name'])
示例15: main
# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import get_appsettings [as 别名]
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
init_social(get_settings(app_settings), Base, DBSession)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)