Пример #1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings, root_factory='flog.models.rootfactory.RootFactory')
    
    config.set_authentication_policy(AuthTktAuthenticationPolicy('flogkrit', hashalg='sha512'))
    config.set_authorization_policy(ACLAuthorizationPolicy())
    config.set_default_permission('edit')

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('shift', '/shift/{date}')
    config.add_route('show', '/show/{id}')
    config.add_route('about', '/about')
    config.add_route('admin', '/admin/')
    config.add_route('settings', '/admin/settings')
    config.add_route('create', '/admin/create/{date}')
    config.add_route('delete', '/admin/delete/{id}')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    config.scan()
    return config.make_wsgi_app()
Пример #2
0
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = Posting(title='First flog post', text='*This* is a new flog post.')
        DBSession.add(model)

    with transaction.manager:
        model = Settings(
                title='This is a new *flog*',
                about='h1. About me\n\nI don\'t have to say anything about me.',
                user='******',
                password='******')
        DBSession.add(model)
Пример #3
0
 def by_user(cls, user):
     return DBSession.query(Settings).filter(Settings.user == user).first()