Exemplo n.º 1
0
def inject_request(event):
    request = event.request

    from pokedex.db.markdown import PokedexLinkExtension
    class VeekunExtension(PokedexLinkExtension):
        def object_url(self, category, obj):
            # XXX this probably does not need to be a closure-class
            return request.resource_url(obj)

    # XXX this spews warnings; may or may not be a problem
    session.configure(markdown_extension_class=VeekunExtension)
Exemplo n.º 2
0
def inject_request(event):
    request = event.request

    from pokedex.db.markdown import PokedexLinkExtension

    class VeekunExtension(PokedexLinkExtension):
        def object_url(self, category, obj):
            # XXX this probably does not need to be a closure-class
            return request.resource_url(obj)

    # XXX this spews warnings; may or may not be a problem
    session.configure(markdown_extension_class=VeekunExtension)
Exemplo n.º 3
0
def main(global_config, **settings):
    """Builds and returns a wsgi app."""

    # Connect to ye db
    engine = engine_from_config(settings, 'sqlalchemy.')
    session.configure(bind=engine)

    config = Configurator(settings=settings, root_factory=LanguageIndex)
    config.add_resource_url_adapter(PokedexURLGenerator)

    # i18n gunk
    config.add_subscriber(inject_globals, 'pyramid.events.BeforeRender')
    config.add_subscriber(inject_request, 'pyramid.events.NewRequest')
    config.add_translation_dirs('veekun_pokedex:locale/')

    config.add_route('main', '/')
    config.scan()

    config.add_static_view('images', 'veekun_pokedex:assets/images')

    # PySCSS support
    config.include('pyramid_scss')
    config.add_route('pyscss', '/css/{css_path:[^/]+}.css')
    config.add_view(route_name='pyscss',
                    view='pyramid_scss.controller.get_scss',
                    renderer='scss',
                    request_method='GET')

    # F*****g around
    config.add_route('api-test', '/pokemon/eevee.json')
    config.add_route('api-search-test', '/api/pokemon/search')
    config.add_route('move-search', '/en/moves')

    config.add_route('tools.tournament', '/tools/tournament')
    config.add_route('tools.compare', '/tools/compare')
    config.add_route('tools.pokeballs', '/tools/pokeballs')
    config.add_route('tools.stats', '/tools/stats')

    return config.make_wsgi_app()
Exemplo n.º 4
0
def main(global_config, **settings):
    """Builds and returns a wsgi app."""

    # Connect to ye db
    engine = engine_from_config(settings, 'sqlalchemy.')
    session.configure(bind=engine)

    config = Configurator(settings=settings, root_factory=LanguageIndex)
    config.add_resource_url_adapter(PokedexURLGenerator)

    # i18n gunk
    config.add_subscriber(inject_globals, 'pyramid.events.BeforeRender')
    config.add_subscriber(inject_request, 'pyramid.events.NewRequest')
    config.add_translation_dirs('veekun_pokedex:locale/')

    config.add_route('main', '/')
    config.scan()

    config.add_static_view('images', 'veekun_pokedex:assets/images')

    # PySCSS support
    config.include('pyramid_scss')
    config.add_route('pyscss', '/css/{css_path:[^/]+}.css')
    config.add_view(route_name='pyscss', view='pyramid_scss.controller.get_scss', renderer='scss', request_method='GET')

    # F*****g around
    config.add_route('api-test', '/pokemon/eevee.json')
    config.add_route('api-search-test', '/api/pokemon/search')
    config.add_route('move-search', '/en/moves')

    config.add_route('tools.tournament', '/tools/tournament')
    config.add_route('tools.compare', '/tools/compare')
    config.add_route('tools.pokeballs', '/tools/pokeballs')
    config.add_route('tools.stats', '/tools/stats')

    return config.make_wsgi_app()