2

I'm testing web.py and forms but I cant get any value in return. This is the code:

import web
from web import form
class add:
    def GET(self):
        f = login()
        return render.formtest(f)

    def POST(self): 
        f = login()
        print f["ip"].value
        return render.formpost(f)

render = web.template.render('templates/')      
login = form.Form(
    form.Textbox("ip", id="ip"),
    form.Textbox('snmp_community'),
)

urls = ( '/','index', '/add', 'add')
app = web.application(urls,globals())
if __name__ == "__main__": app.run()

I followed this example: http://webpy.org/form but when I print the value of f["ip"].value or f.d.ip I always get "None".

Thank you for the help.

1
  • Can you fix your indentation? As it stands now, this won't run. Commented Feb 12, 2012 at 15:19

1 Answer 1

6

Here is a line from the web.py doc:

Note: You cannot access form values before having validated the form!

so you'll have to call f.validates() before you can access the posted data.

Sign up to request clarification or add additional context in comments.

1 Comment

great, now it works! I missed that line on the documentation, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.