當前位置: 首頁>>代碼示例>>Python>>正文


Python paster.get_appsettings方法代碼示例

本文整理匯總了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() 
開發者ID:eoyilmaz,項目名稱:stalker_pyramid,代碼行數:19,代碼來源:initializedb.py

示例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() 
開發者ID:mars-street-view,項目名稱:mars-street-view,代碼行數:22,代碼來源:initializedb.py

示例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) 
開發者ID:hhucn,項目名稱:dbas,代碼行數:22,代碼來源:initializedb.py

示例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() 
開發者ID:tian-lan,項目名稱:CNX_Flip,代碼行數:25,代碼來源:initialize_db.py

示例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) 
開發者ID:conversence,項目名稱:idealoom,代碼行數:26,代碼來源:clone_discussion.py

示例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) 
開發者ID:conversence,項目名稱:idealoom,代碼行數:24,代碼來源:clone_database.py

示例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) 
開發者ID:conversence,項目名稱:idealoom,代碼行數:22,代碼來源:__init__.py

示例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 
開發者ID:asif-mahmud,項目名稱:pyramid_runner,代碼行數:13,代碼來源:base.py

示例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 
開發者ID:websauna,項目名稱:pyramid_notebook,代碼行數:12,代碼來源:conftest.py

示例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 
開發者ID:BirkbeckCTP,項目名稱:annotran,代碼行數:13,代碼來源:conftest.py

示例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') 
開發者ID:aptise,項目名稱:peter_sslers,代碼行數:10,代碼來源:tests.py

示例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 
開發者ID:mars-street-view,項目名稱:mars-street-view,代碼行數:16,代碼來源:conftest.py

示例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']) 
開發者ID:hhucn,項目名稱:dbas,代碼行數:34,代碼來源:initializedb.py

示例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']) 
開發者ID:hhucn,項目名稱:dbas,代碼行數:29,代碼來源:initializedb.py

示例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) 
開發者ID:python-social-auth,項目名稱:social-examples,代碼行數:13,代碼來源:initializedb.py


注:本文中的pyramid.paster.get_appsettings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。