本文整理汇总了Python中pyramid.config.Configurator.register_download方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.register_download方法的具体用法?Python Configurator.register_download怎么用?Python Configurator.register_download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.register_download方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['route_patterns'] = {
'languages': '/language',
'language': '/language/{id:[^/\.]+}',
'unit': '/word/{id:[^/\.]+}',
'parameters': '/meaning',
'parameter': '/meaning/{id:[^/\.]+}',
'contributions': '/vocabulary',
'contribution': '/vocabulary/{id:[^/\.]+}',
'contributors': '/contributor',
'contributor': '/contributor/{id:[^/\.]+}',
'semanticfields': '/semanticfield',
'semanticfield': '/semanticfield/{id:[^/\.]+}',
'legal': '/about/legal',
}
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(WoldMapMarker(), IMapMarker),
config.register_resource(
'semanticfield', SemanticField, ISemanticField, with_index=True)
config.register_download(N3(Dataset, 'wold2', description="RDF dump"))
config.register_download(N3Dump(Parameter, 'wold2', description="Meanings as RDF"))
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['route_patterns'] = {
'contributions': '/inventories',
'contribution': '/inventories/view/{id:[^/\.]+}',
}
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(PhoibleMapMarker(), interfaces.IMapMarker)
config.registry.registerUtility(PhoibleCtxFactoryQuery(), interfaces.ICtxFactoryQuery)
config.add_static_view('data', 'phoible:static/data')
config.register_download(RdfDump(Dataset, 'phoible', description='RDF dump'))
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['sitemaps'] = 'pair parameter source'.split()
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(waabMapMarker(), IMapMarker)
config.register_resource('pair', models.Pair, IPair, with_index=True)
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('about', lambda c, r: (r.route_url('about'), 'About')),
('languages', partial(menu_item, 'languages')),
('pairs', partial(menu_item, 'pairs')),
('parameters', partial(menu_item, 'parameters')),
('sources', partial(menu_item, 'sources')),
)
config.register_download(Download(
Source, 'waab', ext='bib', description="Sources as BibTeX"))
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['route_patterns'] = {'walss': '/wals', 'wals': '/wals/{id:[^/\.]+}'}
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(ApicsCtxFactoryQuery(), ICtxFactoryQuery)
config.registry.registerUtility(ApicsMapMarker(), IMapMarker)
config.registry.registerUtility(link_attrs, ILinkAttrs)
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('contributions', partial(menu_item, 'contributions')),
('parameters', partial(menu_item, 'parameters')),
('apics_wals', lambda ctx, rq: (rq.route_url('walss'), u'WALS\u2013APiCS')),
('surveys', partial(menu_item, 'surveys')),
('sentences', partial(menu_item, 'sentences')),
('sources', partial(menu_item, 'sources')),
('contributors', partial(menu_item, 'contributors')),
)
config.register_adapter(
{
"base": Representation,
"mimetype": 'application/vnd.clld.chapter+html',
"send_mimetype": "text/html",
"extension": 'chapter.html',
"template": 'parameter/chapter_html.mako',
},
IParameter,
name="application/vnd.clld.chapter+html")
config.register_download(CsvDump(
common.Language, 'apics', description="Languages as CSV"))
config.register_download(N3Dump(
common.Language, 'apics', description="Languages as RDF"))
config.register_download(Download(
common.Source, 'apics', ext='bib', description="Sources as BibTeX"))
config.register_resource('wals', Wals, IWals, with_index=True)
config.register_resource('survey', Survey, ISurvey, with_index=True)
config.register_adapters([(
ISurvey,
Representation,
'application/vnd.clld.md+xml',
'md.html',
'md_html.mako',
{'rel': 'describedby'})])
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['route_patterns'] = {'walss': '/wals', 'wals': '/wals/{id:[^/\.]+}'}
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(ApicsCtxFactoryQuery(), ICtxFactoryQuery)
config.registry.registerUtility(ApicsMapMarker(), IMapMarker)
config.registry.registerUtility(frequency_marker, IFrequencyMarker)
config.registry.registerUtility(link_attrs, ILinkAttrs)
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('contributions', partial(menu_item, 'contributions')),
('parameters', partial(menu_item, 'parameters')),
('apics_wals', lambda ctx, rq: (rq.route_url('walss'), u'WALS\u2013APiCS')),
('sentences', partial(menu_item, 'sentences')),
('sources', partial(menu_item, 'sources')),
('contributors', partial(menu_item, 'contributors')),
)
config.register_download(CsvDump(
common.Language, 'apics', description="Languages as CSV"))
config.register_download(N3Dump(
common.Language, 'apics', description="Languages as RDF"))
config.register_download(Download(
common.Source, 'apics', ext='bib', description="Sources as BibTeX"))
config.register_download(Sqlite(
common.Dataset, 'apics', description="APiCS database as sqlite3"))
config.register_resource('wals', Wals, IWals, with_index=True)
config.add_route('chapters', '/admin/chapters')
config.add_route('chapter', '/admin/chapters/{id}')
config.add_route('surveys', '/admin/surveys')
config.add_route('survey', '/admin/surveys/{id}')
return config.make_wsgi_app()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings.update(CFG)
settings['navbar.inverse'] = True
settings['route_patterns'] = {
'languages': '/glottolog/language',
'language': '/resource/languoid/id/{id:[^/\.]+}',
'source': '/resource/reference/id/{id:[^/\.]+}',
'sources': '/langdoc',
#'provider': '/langdoc/langdocinformation#provider-{id}',
'providers': '/langdoc/langdocinformation',
}
settings['sitemaps'] = ['language', 'source']
config = Configurator(settings=settings)
#
# Note: The following routes must be registered before including the clld web app,
# because they are special cases of a more general route pattern registered there.
#
config.add_route('languoid.xhtml', '/resource/languoid/id/{id:[^/\.]+}.xhtml')
config.add_route('reference.xhtml', '/resource/reference/id/{id:[^/\.]+}.xhtml')
config.include('clldmpg')
config.registry.registerUtility(GLCtxFactoryQuery(), ICtxFactoryQuery)
config.register_menu(
#('dataset', partial(menu_item, 'dataset', label='Home')),
('languages', partial(menu_item, 'languages', label='Languages')),
('families', partial(menu_item, 'glottolog.families', label='Families')),
('search', partial(menu_item, 'glottolog.languages', label='Language Search')),
('sources', partial(menu_item, 'sources', label='References')),
('query', partial(menu_item, 'langdoc.complexquery', label='Reference Search')),
('about', partial(menu_item, 'about', label='About')),
)
config.register_resource('provider', models.Provider, IProvider, with_index=True)
config.register_adapter(
adapter_factory('provider/index_html.mako', base=Index), IProvider)
config.add_view(views.redirect_languoid_xhtml, route_name='languoid.xhtml')
config.add_view(views.redirect_reference_xhtml, route_name='reference.xhtml')
config.add_route_and_view('news', '/news', views.news, renderer='news.mako')
config.add_route_and_view(
'glottolog.meta',
'/glottolog/glottologinformation',
views.glottologmeta,
renderer='glottologmeta.mako')
config.add_route_and_view(
'glottolog.families',
'/glottolog/family',
views.families,
renderer='families.mako')
config.add_route_and_view(
'glottolog.iso',
'/resource/languoid/iso/{id:[^/\.]+}',
views.iso)
config.add_route_and_view(
'glottolog.languages',
'/glottolog',
views.languages,
renderer='language/search_html.mako')
config.add_route_and_view(
'glottolog.childnodes',
'/db/getchildlects',
views.childnodes,
renderer='json')
config.add_route_and_view(
'langdoc.complexquery',
'/langdoc/complexquery',
views.langdoccomplexquery,
renderer='langdoccomplexquery.mako')
for name in 'credits glossary cite downloads contact'.split():
pp = '/' if name == 'credits' else '/meta/'
config.add_route_and_view(
'home.' + name,
pp + name,
getattr(views, name),
renderer=name + '.mako')
config.register_download(adapters.LanguoidCsvDump(
models.Languoid, 'glottolog3', description="Languoids as CSV"))
config.register_download(adapters.LanguoidN3Dump(
Language, 'glottolog3', description="Languoids as RDF"))
config.register_download(Download(
Source, 'glottolog3', ext='bib', description="References as BibTeX"))
config.register_download(N3Dump(
Source, 'glottolog3', description="References as RDF"))
config.add_route('langdocstatus', '/langdoc/status')
config.add_route('langdocstatus.browser', '/langdoc/status/browser')
config.add_route(
'langdocstatus.languages', '/langdoc/status/languages-{ed:[0-9]}-{sdt:[0-9]}')
config.scan('glottolog3.langdocstatus')
config.register_datatable('providers', Providers)
return config.make_wsgi_app()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_download [as 别名]
#.........这里部分代码省略.........
extension='tab',
name='tab-separated values'),
dict(
template='parameter/detail_xml.mako',
mimetype='application/vnd.clld.xml',
send_mimetype="application/xml",
extension='xml',
name='WALS XML',
__doc__="Custom XML format."),
dict(
template='parameter/detail_georss.mako',
mimetype='application/vnd.clld.georss+xml',
send_mimetype="application/rdf+xml",
extension='georss',
name="GeoRSS",
__doc__="RSS with location information "
"(http://en.wikipedia.org/wiki/GeoRSS)."),
dict(
template='parameter/detail_kml.mako',
mimetype='application/vnd.google-earth.kml+xml',
send_mimetype="application/xml",
extension='kml',
name='KML',
__doc__="Keyhole Markup Language"),
]:
config.register_adapter(spec, IParameter)
config.add_route('feature_info', '/feature-info/{id}')
config.add_route('genealogy', '/languoid/genealogy')
config.add_301(
'/index',
lambda req: req.route_url('dataset'))
config.add_301(
'/.{ext}',
lambda req: req.route_url('dataset_alt', ext=req.matchdict['ext']))
config.add_301(
'/example/{fid}/all',
lambda req: req.route_url('parameter', id=req.matchdict['fid']))
config.add_301(
'/example/all/wals_code_{lid}',
lambda req: req.route_url(
'sentences', _query=dict(language=req.matchdict['lid'])))
# we redirect legacy urls for datapoints because they could not be expressed
# with a single id.
def datapoint(req):
data = {k: v for k, v in req.matchdict.items()}
if data['fid'][-1] not in ascii_uppercase:
data['fid'] += 'A'
return req.route_url(
'valueset', id='%(fid)s-%(lid)s' % data, _query=req.query_params)
config.add_301('/datapoint/{fid}/wals_code_{lid}', datapoint, name='datapoint')
# we redirect legacy urls for feature combinations because they could not be expressed
# with a single id.
def combined(req):
return req.route_url(
'combination', id='%(id1)s_%(id2)s' % req.matchdict, _query=req.query_params)
config.add_301('/feature/combined/{id1}/{id2}', combined, name='combined')
config.add_301(
"/feature/description/{id:[0-9]+}",
lambda req: req.route_url('contribution', id=req.matchdict['id']))
config.add_301(
"/languoid/by_geography",
lambda req: req.route_url('country', id=req.params.get('country')))
config.add_301(
"/wals-2011-{fid}",
lambda req: req.route_url('parameter', id=req.matchdict.get('fid')))
config.add_301('/languoid/lect', lambda req: req.route_url('languages'))
config.add_301('/languoid/family', lambda req: req.route_url('languages'))
config.add_301('/languoid/genus', lambda req: req.route_url('languages'))
config.add_301('/supplement/1', lambda req: req.route_url('contribution', id='s1'))
config.add_301('/supplement/3', lambda req: req.route_url('contribution', id='s1'))
config.add_301('/supplement/5', lambda req: req.route_url('contribution', id='s5'))
config.add_301('/supplement/6', lambda req: req.route_url('contribution', id='s6'))
config.add_301('/supplement/7', lambda req: req.route_url('contribution', id='s7'))
config.add_301('/supplement/8', lambda req: req.route_url('contribution', id='s8'))
config.add_301('/supplement/9', lambda req: req.route_url('contribution', id='s9'))
for pattern in ['/refdb/', '/refdb/record', '/refdb/record/', '/refdb/search']:
config.add_301(pattern, lambda req: req.route_url('sources'))
config.add_410('/languoid/osd.{ext}')
config.add_410("/experimental/{id}")
config.add_route('olac.source', '/refdb_oai')
config.add_route('languoids', '/languoids')
config.register_download(
Matrix(Language, 'wals3', description="Feature values CSV"))
config.register_download(
Download(Source, 'wals3', ext='bib', description="Sources as BibTeX"))
return config.make_wsgi_app()