当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.configure方法代码示例

本文整理汇总了Python中nextgisbio.models.DBSession.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.configure方法的具体用法?Python DBSession.configure怎么用?Python DBSession.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nextgisbio.models.DBSession的用法示例。


在下文中一共展示了DBSession.configure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2 and len(argv) != 3:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    dir_name = dump_data()
    if len(argv) == 3 and argv[2] == '--make-id-start-0':
        id_verificator.start(dir_name)
开发者ID:nextgis,项目名称:nextgisbio,代码行数:13,代码来源:dump.py

示例2: main

# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2 and len(argv) != 3:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    script_dir = os.path.dirname(__file__)
    rel_path_source_data = "../source_data/"
    source_data_dir = os.path.join(script_dir, rel_path_source_data)
    parse_data(source_data_dir)
    verify_ids()
开发者ID:nextgis,项目名称:nextgisbio,代码行数:15,代码来源:verify_data_by_csv.py

示例3: main

# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    usage = 'usage: %prog -i INPUTFILE  -c <config_uri>\n (example: "%prog -i data.scv  development.ini")'
    parser = OptionParser(usage = usage)
    parser.add_option("-i", "--input", dest="infile",
        action='store', type="string", help="read csv from INPUT file")
    parser.add_option("-c", "--config", dest="config",
        action='store', type="string", help="config file")
        
    (options, args) = parser.parse_args()
    if options.infile == None or options.config == None:
        parser.error("incorrect number of arguments")
    config_uri = options.config
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    
    # Заполним таблицы данными:
    gen_sql(read_data(options.infile))
开发者ID:nextgis,项目名称:nextgisbio,代码行数:21,代码来源:gen_taxon.py

示例4: main

# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import configure [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    my_session_factory = UnencryptedCookieSessionFactoryConfig('sosecret')
    authn_policy = AuthTktAuthenticationPolicy('sosecret', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=my_session_factory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy
    )
    config.include('pyramid_mako')

    config.add_static_view('static', 'nextgisbio:static', cache_max_age=3600)
    config.add_static_view('contrib', 'nextgisbio:contrib', cache_max_age=3600)

    config.add_route('home', '/', factory=RootFactory)
    config.add_route('taxons_editor', '/taxons/editor', factory=RootFactory)

    config.add_route('login', '/login', factory=RootFactory)
    config.add_route('logout', '/logout', factory=RootFactory)

    config.add_route('taxon_filter', '/taxon/filter', factory=RootFactory)
    config.add_route('species_name', '/species', factory=RootFactory)
    config.add_route('taxon_direct_child', '/taxon/direct_child',      factory=RootFactory)
    config.add_route('get_taxon_path', '/taxon/path/{id}',  factory=RootFactory)
    config.add_route('taxon_type', '/taxon/type/{id}',       factory=RootFactory)
    config.add_route('taxon_cbtree', '/cbtree/taxons', factory=RootFactory)
    config.add_route('get_taxon_tree_childrens', '/tree/taxons/{taxon_parent_id}', factory=RootFactory)
    config.add_route('taxon_tree', '/tree/taxons/', factory=RootFactory)
    config.add_route('get_child_taxons_by_parent', '/taxon/child', factory=RootFactory)
    config.add_route('get_taxon', '/taxon/{id}', factory=RootFactory)

    config.add_route('get_synonyms', 'taxons/synonyms/{taxon_id}/', factory=RootFactory)
    config.add_route('synonyms_by_taxon', 'taxons/synonyms/{taxon_id}/{synonym_id}', factory=RootFactory)

    # reports
    config.add_route('protected_species_list', '/reports/protected_species_list', factory=RootFactory)
    config.add_route('redbook_filter', '/redbook/filter', factory=RootFactory)
    config.add_route('species_by_redbook', '/species/redbook/{redbook_id}', factory=RootFactory)

    # Фильтр видов по его типу, подстроки названия и (если указан) id
    config.add_route('species_filter',    '/species/{type}/{id:[0-9]*}',       factory=RootFactory)

    # Карточки наблюдений, где был описан определенный таксон:
    config.add_route('points_text',         '/points_text/',            factory=RootFactory)

    # Экспорт карточек наблюдений
    config.add_route('cards_download',  '/cards_download/{format}/',    factory=RootFactory)
    # Создание новой карточки наблюдения 
    config.add_route('new_card',            '/cards/new',               factory=RootFactory)
    # Сохранить карточку после редактирования
    config.add_route('save_card',           '/cards/save',         factory=RootFactory)
    # Карточка наблюдений в формате json
    config.add_route('cards_view',          '/cards/{id}',              factory=RootFactory)

    config.add_route('card',          '/card/{id}',              factory=RootFactory)

    config.add_route('get_card_images', '/card/{id}/images', factory=RootFactory)

    # Аннотированные списки в квадрате № id, с описанем определенного таксона:
    config.add_route('anns_text',         '/anns_text/square/{id}',     factory=RootFactory)
    # Экспорт аннотированных списков
    config.add_route('anns_download',  '/anns_download/{format}/',      factory=RootFactory)
    # Создание нового анн. списка
    config.add_route('new_anlist',          '/annotation/new',          factory=RootFactory)
    # Сохранить анн. список после редактирования
    config.add_route('save_anlist',         '/annotation/save',    factory=RootFactory)

    config.add_route('annotation',         '/annotation/{id}',    factory=RootFactory)

    # Квадраты и ключевые участки
    config.add_route('squares_text',        '/squares_text/',           factory=RootFactory)
    # Квадрат и ключевые участки, на которые он попадает
    config.add_route('square',              '/square/{id}',             factory=RootFactory)
    # Аннотации по ключевому участку
    config.add_route('karea_ann',           '/key_area/{id}/ann',       factory=RootFactory)

    # Квадраты, где был найден определенный таксон:
    config.add_route('areal_text',          '/areal_text/',             factory=RootFactory)
    # Квадраты, где был найден определенный таксон:
    config.add_route('areal_download',      '/areal/download/',         factory=RootFactory)

    # Выдать данные из таблицы связей квадраты-КУ в формате csv
    config.add_route('s_ka_association_download',  'association_download',       factory=RootFactory)

    config.add_route('upload_image', '/images/upload/{type}/{id}', factory=RootFactory)
    config.add_route('remove_image', '/images/remove/{type}/{image_id}', factory=RootFactory)

    config.add_route('cards_table', '/cards/table/', factory=RootFactory)
    config.add_route('cards_jtable_browse', '/cards/manager/jtable/list', factory=RootFactory)
    config.add_route('cards_by_user', '/reports/cards_by_user/', factory=RootFactory)
    config.add_route('cards_by_user_jtable_browse', '/reports/cards_by_user/jtable/list', factory=RootFactory)

    config.add_route('export_cards_table', '/export/cards/', factory=RootFactory)
#.........这里部分代码省略.........
开发者ID:nextgis,项目名称:nextgisbio,代码行数:103,代码来源:__init__.py

示例5: main

# 需要导入模块: from nextgisbio.models import DBSession [as 别名]
# 或者: from nextgisbio.models.DBSession import configure [as 别名]
def main(argv=sys.argv):
    if len(argv) != 2 and len(argv) != 3:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    md5_pass = False
    if len(argv) == 3 and argv[2] == '--md5-pass':
        md5_pass = True

    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    # Заполним таблицы данными:

    # Таксоны
    taxons_file = 'nextgisbio/initial_data/csv/taxon.csv'
    Taxon.add_from_file(taxons_file)

    synonym_file = 'nextgisbio/initial_data/csv/synonym.csv'
    Synonym.add_from_file(synonym_file)

    # Справочники

    person_file = 'nextgisbio/initial_data/csv/person.csv'
    Person.add_from_file(person_file)

    taxa_file = 'nextgisbio/initial_data/csv/taxa_scheme.csv'
    Taxa_scheme.add_from_file(taxa_file)

    museum_file = 'nextgisbio/initial_data/csv/museum.csv'
    Museum.add_from_file(museum_file)

    coord_type_file = 'nextgisbio/initial_data/csv/coord_type.csv'
    Coord_type.add_from_file(coord_type_file)

    ant_file = 'nextgisbio/initial_data/csv/anthr_press.csv'
    Anthr_press.add_from_file(ant_file)

    vital_file = 'nextgisbio/initial_data/csv/vitality.csv'
    Vitality.add_from_file(vital_file)

    abundance_file = 'nextgisbio/initial_data/csv/abundance.csv'
    Abundance.add_from_file(abundance_file)

    footprint_file = 'nextgisbio/initial_data/csv/footprint.csv'
    Footprint.add_from_file(footprint_file)

    pheno_file = 'nextgisbio/initial_data/csv/pheno.csv'
    Pheno.add_from_file(pheno_file)

    infores_file = 'nextgisbio/initial_data/csv/inforesources.csv'
    Inforesources.add_from_file(infores_file)

    area_type_file = 'nextgisbio/initial_data/csv/area_type.csv'
    Area_type.add_from_file(area_type_file)

    legend_file = 'nextgisbio/initial_data/csv/legend.csv'
    Legend.add_from_file(legend_file)

    key_area_file = 'nextgisbio/initial_data/csv/key_area.csv'
    Key_area.add_from_file(key_area_file)

    # Нужно добавить шейпы и заполнить данными таблицу
    # связей (square_keyarea_association) многие-ко-многим между Squares и Key_area
    shp_file = 'nextgisbio/initial_data/shp/key_areas_25km.shp'
    association_file = 'nextgisbio/initial_data/csv/square_karea_association.csv'
    Squares.add_from_file(association_file, shp_file)

    # Карточки и аннотации
    cards_file = 'nextgisbio/initial_data/csv/cards.csv'
    Cards.add_from_file(cards_file)

    ann_file = 'nextgisbio/initial_data/csv/annotation.csv'
    Annotation.add_from_file(ann_file)

    # Пользователи
    users_file = 'nextgisbio/initial_data/csv/user.csv'
    User.add_from_file(users_file, md5_pass)

    red_books_csv = 'nextgisbio/initial_data/csv/redbooks.csv'
    RedBook.import_from_csv(red_books_csv)

    images_csv = 'nextgisbio/initial_data/csv/images.csv'
    Images.import_from_csv(images_csv)

    cards_images_csv = 'nextgisbio/initial_data/csv/cards_images.csv'
    CardsImages.import_from_csv(cards_images_csv)
开发者ID:nextgis,项目名称:nextgisbio,代码行数:93,代码来源:initializedb.py


注:本文中的nextgisbio.models.DBSession.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。