def step3():
    response.view = 'wizard/step.html'
    n = int(request.args(-1) or 0)
    m = len(session.app['tables'])
    if n >= m:
        redirect(URL('step2'))
    table = session.app['tables'][n]
    form = SQLFORM.factory(Field('field_names', 'list:string',
                                 default=session.app.get('table_' + table, [])), _class="span7 well well-small")
    if form.accepts(request.vars) and form.vars.field_names:
        fields = listify(form.vars.field_names)
        if table == 'auth_user':
            for field in ['first_name', 'last_name', 'username', 'email', 'password']:
                if not field in fields:
                    fields.append(field)
        session.app['table_' + table] = [t.strip().lower()
                                         for t in listify(form.vars.field_names)
                                         if t.strip()]
        try:
            tables = sort_tables(session.app['tables'])
        except RuntimeError:
            response.flash = T('invalid circular reference')
        else:
            if n < m - 1:
                redirect(URL('step3', args=n + 1) + '/#xwizard_form')
            else:
                redirect(URL('step4') + '/#xwizard_form')
    return dict(step='3: Fields for table "%s" (%s of %s)'
                % (table, n + 1, m), table=table, form=form)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/applications-original/admin/controllers/wizard.py/step3/original