Exemplo n.º 1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    settings["db.sessionmaker"] = DBSession
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    initialize_sql(engine, [populate, populate_wiki, populate_feeds])
    session_factory = session_factory_from_settings(settings)
    root_factory = "trumpet.resources.RootGroupFactory"
    request_factory = "trumpet.request.AlchemyRequest"
    config = Configurator(
        settings=settings,
        root_factory=root_factory,
        request_factory=request_factory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory,
    )
    configure_static(config)

    # config.include('pyramid_fanstatic')
    configure_base_layout(config)

    config.add_static_view("static", "static", cache_max_age=3600)
    config.add_route("home", "/")
    config.add_view("plum.views.MainViewer", route_name="home", renderer=basetemplate, layout="base")

    configure_login(config)
    configure_rssviewer(config, "/rssviewer")
    configure_wiki(config, "/wiki")

    return config.make_wsgi_app()
Exemplo n.º 2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    settings['db.sessionmaker'] = DBSession
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    initialize_sql(engine, [populate,
                            populate_sitetext,
                            populate_wiki,
                            populate_feeds,
                            populate_ticket_status])
    root_factory = 'trumpet.resources.RootGroupFactory'
    request_factory = 'trumpet.request.AlchemyRequest'
    session_factory = session_factory_from_settings(settings)
    config = Configurator(settings=settings,
                          root_factory=root_factory,
                          request_factory=request_factory,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.set_session_factory(session_factory)

    configure_static(config)
    configure_base_layout(config)
    
    config.add_static_view('static', 'kermas:static', cache_max_age=3600)

    config.add_route('home', '/')
    add_view(config, 'kermas.views.main.MainViewer', 'home')

    config.add_route('status', '/status/{context}')
    add_view(config, 'kermas.views.eddie.status.StatusViewer', 'status')

    config.add_route('portacopy', '/portacopy/{context}/{id}')
    config.add_view('kermas.views.portacopy.PortaCopyViewer',
                    route_name='portacopy',
                    renderer=basetemplate,
                    layout='base',
                    permission='admin')

    
    configure_login(config)
    configure_admin(config)
    configure_sitecontent(config)

    configure_wiki(config, '/wiki')
    configure_rssviewer(config, '/rssviewer')
    configure_consultant(config)
    
    
    #config.scan()
    return config.make_wsgi_app()
Exemplo n.º 3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    settings["db.sessionmaker"] = DBSession
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    initialize_sql(engine, [populate, populate_wiki, populate_feeds, populate_images, populate_sitetext])
    session_factory = session_factory_from_settings(settings)
    root_factory = "trumpet.resources.RootGroupFactory"
    request_factory = "trumpet.request.AlchemyRequest"
    # setup authn and authz
    appname = "demo"
    secret = settings["%s.authn.secret" % appname]
    cookie = settings["%s.authn.cookie" % appname]
    timeout = int(settings["%s.authn.timeout" % appname])
    authn_policy, authz_policy = make_authn_authz_policies(
        secret, cookie, callback=authenticate, timeout=timeout, tkt=False
    )

    config = Configurator(
        settings=settings,
        root_factory=root_factory,
        request_factory=request_factory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory,
    )
    config.include("cornice")
    configure_frontdoor(config)
    configure_static(config)
    configure_base_layout(config)

    config.add_static_view("static", "static", cache_max_age=3600)
    config.add_route("home", "/")
    config.add_view("trumpet.views.frontdoor.FrontDoorView", route_name="home")

    # configure_login(config)
    # configure_rssviewer(config, '/rssviewer')
    # configure_wiki(config, '/wiki')
    # configure_admin(config)
    # configure_sitecontent(config)
    # configure_consultant(config)
    config.scan("trumpet.views.rest.users")
    config.scan("trumpet.views.rest.webview")
    config.scan("trumpet.views.rest.sitecontent")
    config.scan("trumpet.views.rest.simplerss")

    configure_webviews(config)

    return config.make_wsgi_app()
Exemplo n.º 4
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    settings['db.sessionmaker'] = DBSession
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    if True:
        import transaction
        Base.metadata.create_all(engine)
        with transaction.manager:
            model = MyModel(name='one', value=1)
            DBSession.add(model)
            initialize_sql(engine, [populate,
                                    populate_wiki,
                                    populate_feeds])
    session_factory = session_factory_from_settings(settings)
    root_factory = 'trumpet.resources.RootGroupFactory'
    request_factory = 'trumpet.request.AlchemyRequest'
    config = Configurator(settings=settings,
                          root_factory=root_factory,
                          request_factory=request_factory,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy,
                          session_factory=session_factory)
    configure_static(config)
                          
    #config.include('pyramid_fanstatic')
    configure_base_layout(config)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_view('phoebe.views.MainViewer', route_name='home',
                    renderer=basetemplate,
                    layout='base')
    
    configure_login(config)

    #configure_rssviewer(config, '/rssviewer')
    config.add_route('rssviewer', '/rssviewer/{context}/{feed}')
    config.add_view('trumpet.views.rssviewer.MainViewer',
                    route_name='rssviewer', layout='base')

    configure_wiki(config, '/wiki')

    return config.make_wsgi_app()
Exemplo n.º 5
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    # set app name
    appname = 'paellera'
    # need to use goout root factory for ACL
    root_factory = 'paellera.resources.RootGroupFactory'
    # alchemy request provides .db method
    request_factory = 'trumpet.request.AlchemyRequest'
    # get admin username
    admin_username = settings.get('paellera.admin.admin_username', 'admin')
    # create db engine
    engine = engine_from_config(settings, 'sqlalchemy.')
    # setup db.sessionmaker
    settings['db.sessionmaker'] = DBSession
    # bind session to engine
    DBSession.configure(bind=engine)
    # bind objects to engine
    Base.metadata.bind = engine

    if settings.get('db.populate', 'False') == 'True':
        from paellera.models.main import make_test_data
        Base.metadata.create_all(engine)
        #initialize_sql(engine)
        #make_test_data(DBSession)
        from paellera.models.usergroup import populate_groups
        populate_groups()
        from paellera.models.usergroup import populate
        populate(admin_username)
        from paellera.models.sitecontent import populate_sitetext
        populate_sitetext()
        
        
    # setup authn and authz
    secret = settings['%s.authn.secret' % appname]
    cookie = settings['%s.authn.cookie' % appname]
    timeout = int(settings['%s.authn.timeout' % appname])
    authn_policy, authz_policy = make_authn_authz_policies(
        secret, cookie, callback=authenticate,
        timeout=timeout)
    # create config object
    config = Configurator(settings=settings,
                          root_factory=root_factory,
                          request_factory=request_factory,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.include('pyramid_fanstatic')

    configure_base_layout(config)
    configure_admin(config)
    configure_wiki(config, '/pkg_wiki')
    config.add_static_view('static',
                           'paellera:static', cache_max_age=3600)
    ##################################
    # Main Views
    ##################################
    config.add_route('home', '/')
    config.add_view('paellera.views.main.MainViewer',
                    layout='base',
                    renderer=basetemplate,
                    route_name='home')
    config.add_route('main', '/main/{context}/{id}')
    config.add_view('paellera.views.main.MainViewer',
                    layout='base',
                    renderer=basetemplate,
                    route_name='main')
    ##################################
    # Login Views
    ##################################
    login_viewer = 'paellera.views.login.LoginViewer'
    config.add_route('login', '/login')
    config.add_view(login_viewer,
                    renderer=basetemplate,
                    layout='base',
                    route_name='login')
    
    
    config.add_route('logout', '/logout')
    config.add_view(login_viewer,
                    renderer=basetemplate,
                    layout='base',
                    route_name='logout')

    
    # Handle HTTPForbidden errors with a
    # redirect to a login page.
    config.add_view(login_viewer,
                    context='pyramid.httpexceptions.HTTPForbidden',
                    renderer=basetemplate,
                    layout='base')
    ##################################

    ##################################
    # Views for Users
    ##################################
    config.add_route('user', '/user/{context}')
    config.add_view('paellera.views.userview.MainViewer',
                    route_name='user',
                    renderer=basetemplate,
                    layout='base',
                    permission='user')
    
    ##################################
    
    
    # wrap app with Fanstatic
    app = config.make_wsgi_app()
    from fanstatic import Fanstatic
    return Fanstatic(app)
Exemplo n.º 6
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    # set app name
    appname = 'vignewton'
    # need to use goout root factory for ACL
    root_factory = 'vignewton.resources.RootGroupFactory'
    # alchemy request provides .db method
    request_factory = 'trumpet.request.AlchemyRequest'
    # get admin username
    admin_username = settings.get('vignewton.admin.admin_username', 'admin')
    # create db engine
    engine = engine_from_config(settings, 'sqlalchemy.')
    # setup db.sessionmaker
    settings['db.sessionmaker'] = DBSession
    # bind session to engine
    DBSession.configure(bind=engine)
    # bind objects to engine
    Base.metadata.bind = engine

    if settings.get('db.populate', 'False') == 'True':
        from sqlalchemy.exc import IntegrityError
        from vignewton.models.main import make_test_data
        Base.metadata.create_all(engine)
        #initialize_sql(engine)
        #make_test_data(DBSession)
        from vignewton.models.usergroup import populate_groups
        populate_groups()
        from vignewton.models.usergroup import populate
        populate(admin_username)
        from vignewton.models.sitecontent import populate_sitetext
        populate_sitetext()
        import transaction
        
        filename = 'testdata/nfl-teams.csv'
        if os.path.isfile(filename):
            from sqlalchemy.exc import IntegrityError
            from vignewton.managers.nflgames import NFLTeamManager
            from vignewton.managers.util import get_nfl_teams
            m = NFLTeamManager(DBSession)
            teams = get_nfl_teams(filename)
            try:
                m.populate_teams(teams)
            except IntegrityError:
                transaction.abort()
        filename = 'testdata/nfl.ics'
        if os.path.isfile(filename):
            from vignewton.managers.nflgames import NFLGameManager
            m = NFLGameManager(DBSession)
            try:
                m.populate_games(file(filename).read())
            except IntegrityError:
                import transaction
                transaction.abort()
        from vignewton.models.main import populate_accounting_tables
        populate_accounting_tables(DBSession)
        
        
        
    # setup authn and authz
    secret = settings['%s.authn.secret' % appname]
    cookie = settings['%s.authn.cookie' % appname]
    timeout = int(settings['%s.authn.timeout' % appname])
    authn_policy, authz_policy = make_authn_authz_policies(
        secret, cookie, callback=authenticate,
        timeout=timeout, tkt=False)
    # create config object
    config = Configurator(settings=settings,
                          root_factory=root_factory,
                          request_factory=request_factory,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.include('pyramid_fanstatic')

    configure_base_layout(config)
    configure_admin(config)
    configure_wiki(config, '/vig_wiki')
    config.add_static_view('static',
                           'vignewton:static', cache_max_age=3600)
    ##################################
    # Main Views
    ##################################
    config.add_route('home', '/')
    config.add_view('vignewton.views.main.MainViewer',
                    layout='base',
                    renderer=basetemplate,
                    route_name='home')
    config.add_route('main', '/main/{context}/{id}')
    config.add_view('vignewton.views.main.MainViewer',
                    permission='user',
                    layout='base',
                    renderer=basetemplate,
                    route_name='main',)
    config.add_route('initdb', '/initdb/{context}/{id}')
    config.add_view('vignewton.views.main.MainViewer',
                    layout='base',
                    renderer=basetemplate,
                    route_name='initdb')
    route_name = 'maincal_json'
    config.add_route(route_name, '/%s/{context}/{id}' % route_name)
    config.add_view('vignewton.views.main.MainCalJSONViewer',
                    permission='user',
                    route_name=route_name,
                    renderer='json',
                    layout='base',)

    route_name = 'vig_nflteams'
    config.add_route(route_name, '/vignflteams/{context}/{id}')
    config.add_view('vignewton.views.teams.NFLTeamViewer',
                    permission='user',
                    layout='base',
                    renderer=basetemplate,
                    route_name=route_name)

    route_name = 'vig_nflgames'
    config.add_route(route_name, '/vignflgames/{context}/{id}')
    config.add_view('vignewton.views.games.NFLGameViewer',
                    permission='user',
                    layout='base',
                    renderer=basetemplate,
                    route_name=route_name)
    

    route_name = 'vig_betgames'
    config.add_route(route_name, '/vigbetgames/{context}/{id}')
    config.add_view('vignewton.views.betgames.NFLGameBetsViewer',
                    permission='user',
                    layout='base',
                    renderer=basetemplate,
                    route_name=route_name)

    route_name = 'vig_betfrag'
    config.add_route(route_name, '/vigbetfrag/{context}/{id}')
    config.add_view('vignewton.views.betgames.NFLBetFrag',
                    permission='user',
                    layout='base',
                    renderer='string',
                    route_name=route_name)
    
    route_name = 'vig_really_bet'
    match = '/vigmakebet/{game_id}/{bettype}/{amount}/{betval}'
    config.add_route(route_name, match)
    config.add_view('vignewton.views.betgames.NFLGameBetsViewer',
                    permission='user',
                    layout='base',
                    renderer=basetemplate,
                    route_name=route_name)
    
    
    ##################################
    # Login Views
    ##################################
    login_viewer = 'vignewton.views.login.LoginViewer'
    config.add_route('login', '/login')
    config.add_view(login_viewer,
                    renderer=basetemplate,
                    layout='base',
                    route_name='login')
    
    
    config.add_route('logout', '/logout')
    config.add_view(login_viewer,
                    renderer=basetemplate,
                    layout='base',
                    route_name='logout')

    
    # Handle HTTPForbidden errors with a
    # redirect to a login page.
    config.add_view(login_viewer,
                    context='pyramid.httpexceptions.HTTPForbidden',
                    renderer=basetemplate,
                    layout='base')
    ##################################
    config.add_route('blob', '/blob/{filetype}/{id}')
    config.add_view('vignewton.views.blob.BlobViewer', route_name='blob',
                    renderer='string',
                    layout='base')

    ##################################
    # Views for Users
    ##################################
    config.add_route('user', '/user/{context}')
    config.add_view('vignewton.views.userview.MainViewer',
                    route_name='user',
                    renderer=basetemplate,
                    layout='base',
                    permission='user')
    
    ##################################

    
    
    # wrap app with Fanstatic
    app = config.make_wsgi_app()
    from fanstatic import Fanstatic
    return Fanstatic(app)