예제 #1
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
예제 #2
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
예제 #3
0
def newlunch(request):
    form = Form(request, schema=LunchSchema())
    if not form.validate:
        raise exc.HTTPBadRequest

    l = Lunch(
        submitter=request.POST.get('submitter', 'nobody'),
        food=request.POST.get('food', 'nothing'),
    )

    with transaction.manager:
        DBSession.add(l)

    raise exc.HTTPSeeOther('/')
예제 #4
0
def newlunch(request):
    form = Form(request, schema=LunchSchema())
    if not form.validate:
        raise exc.HTTPBadRequest

    l = Lunch(
        submitter=request.POST.get('submitter', 'nobody'),
        food=request.POST.get('food', 'nothing'),
    )

    with transaction.manager:
        DBSession.add(l)

    raise exc.HTTPSeeOther('/')
예제 #5
0
def home(request):
    lunches = DBSession.query(Lunch).all()
    form = Form(request, schema=LunchSchema())
    return {'lunches': lunches, 'form': FormRenderer(form)}
예제 #6
0
def home(request):
    lunches = DBSession.query(Lunch).all()
    form = Form(request, schema=LunchSchema())
    return {'lunches': lunches, 'form': FormRenderer(form)}