本文整理汇总了Python中pyramid.config.Configurator.register_menu方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.register_menu方法的具体用法?Python Configurator.register_menu怎么用?Python Configurator.register_menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.register_menu方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.registry.registerUtility(link_attrs, interfaces.ILinkAttrs)
config.include('clldmpg')
config.include('clld_glottologfamily_plugin')
config.registry.registerUtility(MyMapMarker(), interfaces.IMapMarker)
config.add_page('submit')
config.add_page('help')
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('contributions', partial(menu_item, 'contributions')),
('parameters', partial(menu_item, 'parameters')),
('sentences', partial(menu_item, 'sentences')),
('help', lambda ctx, rq: (rq.route_url('help'), u'Help')),
)
config.add_settings(
home_comp=['submit', 'contributors', 'languages'] +
config.get_settings()['home_comp'])
for cls in [md.BibTex, md.ReferenceManager]:
for if_ in [interfaces.IRepresentation, interfaces.IMetadata]:
config.register_adapter(cls, interfaces.IContribution, if_, name=cls.mimetype)
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
convert = lambda spec: ''.join(c if i == 0 else c + c for i, c in enumerate(spec))
filename_pattern = re.compile('(?P<spec>(c|d|s|f|t)[0-9a-f]{3})\.png')
icons = {}
for fname in sorted(Path(__file__).parent.joinpath('static', 'icons').iterdir()):
m = filename_pattern.match(fname.name)
if m:
icons[m.group('spec')] = convert(m.group('spec'))
settings['icons'] = icons
config = Configurator(settings=settings)
config.include('clldmpg')
config.include('clld_glottologfamily_plugin')
config.registry.registerUtility(NtsMapMarker(), IMapMarker)
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('parameters', partial(menu_item, 'parameters', label='Features')),
('languages', partial(menu_item, 'languages')),
('sources', partial(menu_item, 'sources')),
('designers', partial(menu_item, 'contributions', label="Contributors")),
)
config.register_adapter(adapter_factory(
'parameter/detail_tab.mako',
mimetype='application/vnd.clld.tab',
send_mimetype="text/plain",
extension='tab',
name='tab-separated values'), IParameter)
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [as 别名]
def main(global_config, **settings):
"""called when bootstrapping a pyramid app using clld/tests/test.ini."""
class IF(Interface):
pass
settings['mako.directories'] = ['clld:web/templates']
config = Configurator(settings=settings)
config.include('clld.web.app')
config.registry.registerUtility(MapMarker(), interfaces.IMapMarker)
config.register_staticresource('css', 'clld:web/static/notexisting.css')
config.register_staticresource('js', 'clld:web/static/notexisting.js')
config.register_adapter(Representation, Mock, name='test')
config.register_menu(('home', lambda ctx, req: (req.resource_url(req.dataset), 'tt')))
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [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_menu [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['route_patterns'] = {
'villages': '/geography.cfm',
'parameters': '/thesaurus.cfm',
'sources': '/bibliography.cfm',
'languages': '/languages.cfm',
'florafauna': '/florafauna.cfm',
'bangime': '/bangime.cfm',
'file': '/_files/{id:[^/\.]+}',
'file_alt': '/_files/{id:[^/\.]+}.{ext}',
}
config = Configurator(settings=settings)
config.include('clldmpg')
config.register_menu(
('dataset', partial(menu_item, 'dataset', label='Home')),
('languages', partial(menu_item, 'languages')),
('values', partial(menu_item, 'values', label='Lexicon')),
('parameters', partial(menu_item, 'parameters', label='Thesaurus')),
('villages', partial(menu_item, 'villages', label='Villages')),
('florafauna', partial(menu_item, 'florafauna', label='Flora-Fauna')),
#('contributors', partial(menu_item, 'contributors', label='Project members')),
('sources', partial(menu_item, 'sources', label='Materials')),
#('bangime', partial(menu_item, 'bangime', label='Bangime')),
#('other', partial(menu_item, 'other', label='Other Languages')),
('movies', partial(menu_item, 'movies', label='Videos')),
)
home_comp = config.registry.settings['home_comp']
home_comp = [
'bangime', 'other',
'contributors'] + home_comp
config.add_settings({'home_comp': home_comp})
config.register_resource('village', models.Village, IVillage, with_index=True)
config.register_resource('movie', models.Movie, IMovie, with_index=True)
config.register_resource('file', models.File, IFile, with_index=True)
config.registry.registerUtility(CustomFactoryQuery(), ICtxFactoryQuery)
config.add_page('bangime')
config.add_page('florafauna')
config.add_page('other')
config.add_page('typology')
return config.make_wsgi_app()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [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()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('clldmpg')
config.registry.registerUtility(TsammalexMapMarker(), IMapMarker)
config.registry.settings['home_comp'].append('contributors')
config.register_menu(
('dataset', dict(label='Home')),
'values',
'languages',
'parameters',
'ecoregions',
'sources',
'images',
#('contributors', dict(label='Contribute'))
('contribute', lambda ctx, req: (req.route_url('help'), 'Contribute!'))
)
config.register_resource('ecoregion', models.Ecoregion, IEcoregion, with_index=True)
config.register_resource('image', Parameter_files, IImage, with_index=True)
return config.make_wsgi_app()
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [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()
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import register_menu [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()