Ejemplo n.º 1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)

    # Initialize database
    pyramid_sqla.add_engine(settings, prefix='sqlalchemy.', 
        convert_unicode=True)

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
    config.add_subscriber('simpledemo.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home', '/', 'simpledemo.handlers:MainHandler',
                       action='index')
    config.add_handler('main', '/{action}', 'simpledemo.handlers:MainHandler',
        path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    add_static_route(config, 'simpledemo', 'static', cache_max_age=3600)

    return config.make_wsgi_app()
Ejemplo n.º 2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    # add policies
    authentication_policy = AuthTktAuthenticationPolicy('pyramidhq_seekrit',
                                                        callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          request_factory=request.PylonsHQRequest)

    # initialize database
    pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')

    # configure beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # configure beaker cache regions
    pyramid_beaker.set_cache_regions_from_settings(settings)

    # add i18n dirs
    config.add_translation_dirs('pylonshq:locale/')

    # initialize handlers
    config.include('pyramid_handlers')

    # initialize github client
    config.registry['github'] = init_github(settings)

    # configure renderers
    config.add_subscriber('pylonshq.lib.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')
    config.add_subscriber('pylonshq.lib.subscribers.add_localizer',
                          'pyramid.events.ContextFound')
    config.add_static_view('static', 'pylonshq:static')

    # add mako templating
    config.include('pyramid_mako')

    # set up handlers
    config.include(add_handlers)

    # scan packages
    config.scan('pylonshq')

    return config.make_wsgi_app()
Ejemplo n.º 3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    # add policies
    authentication_policy = AuthTktAuthenticationPolicy('pyramidhq_seekrit',
                                                        callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          request_factory=request.PylonsHQRequest)

    # initialize database
    pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')

    # configure beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # configure beaker cache regions
    pyramid_beaker.set_cache_regions_from_settings(settings)

    # add i18n dirs
    config.add_translation_dirs('pylonshq:locale/')

    # initialize handlers
    config.include('pyramid_handlers')

    # initialize github client
    config.registry['github'] = init_github(settings)

    # configure renderers
    config.add_subscriber('pylonshq.lib.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')
    config.add_subscriber('pylonshq.lib.subscribers.add_localizer',
                          'pyramid.events.ContextFound')
    config.add_static_view('static', 'pylonshq:static')

    # add mako templating
    config.include('pyramid_mako')

    # set up handlers
    config.include(add_handlers)

    # scan packages
    config.scan('pylonshq')

    return config.make_wsgi_app()
Ejemplo n.º 4
0
 def setUp(self):
     from pyramid.config import Configurator
     import pyramid_sqla
     self.engine = pyramid_sqla.add_engine(url='sqlite://')
     self.session = pyramid_sqla.get_session()()
     self.config = Configurator(autocommit=True)
     self.config.begin()
Ejemplo n.º 5
0
 def setUp(self):
     from pyramid.config import Configurator
     import pyramid_sqla
     self.engine = pyramid_sqla.add_engine(url='sqlite://')
     self.session = pyramid_sqla.get_session()()
     self.config = Configurator(autocommit=True)
     self.config.begin()
Ejemplo n.º 6
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)

    config.include('pyramid_handlers')

    # Initialize database
    engine = pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')
    initialize_sql(engine)

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid_jinja2.renderer_factory')
    config.add_subscriber('simplesite.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home',
                       '/',
                       'simplesite.handlers:MainHandler',
                       action='index')

    config.add_handler('add',
                       '/submit/',
                       'simplesite.handlers:MainHandler',
                       action='submit')

    config.add_handler('edit',
                       '/edit/{item_id}/',
                       'simplesite.handlers:MainHandler',
                       action='edit')

    config.add_handler('main',
                       '/{action}',
                       'simplesite.handlers:MainHandler',
                       path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    add_static_route(config, 'simplesite', 'static', cache_max_age=3600)

    return config.make_wsgi_app()
Ejemplo n.º 7
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)

    config.include('pyramid_handlers')

    # Initialize database
    engine = pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')
    initialize_sql(engine)

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid_jinja2.renderer_factory')
    config.add_subscriber('simplesite.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home', '/', 'simplesite.handlers:MainHandler',
                       action='index')
    
    config.add_handler('add', '/submit/', 'simplesite.handlers:MainHandler',
                       action='submit')

    config.add_handler('edit', '/edit/{item_id}/', 
                       'simplesite.handlers:MainHandler',
                       action='edit')


    config.add_handler('main', '/{action}', 'simplesite.handlers:MainHandler',
        path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    add_static_route(config, 'simplesite', 'static', cache_max_age=3600)

    return config.make_wsgi_app()