In your def POST, you need to fill the form. There are a couple ways
to do this:

form = self.searchbox()
form.fill(web.input())

or

form = self.searchbox()
if not form.validates(): # the validates method will fill the form
using web.input() by default
  return render.index(form)


On Nov 19, 2:42 pm, leftcase <[email protected]> wrote:
> Hi,
>
> I'm pretty new to programming in Python, and having previously used it
> in a scripting only capacity in systems administration I've recently
> picked up web.py, and decided to see how it can be applied to
> designing web apps.
>
> At the moment I'm running into what I'm sure will be to you an obvious
> problem, but I keep hitting a brick wall!
>
> When I run this code, I expect to be able to put a value into the
> form, hit submit, and have a page returned which reads 'value was' and
> then the value.
>
> What hitting submit what I actually get is 'value was None'.
>
> Can anyone tell me where I'm going wrong :-S
>
> Thanks,
>
> Chris
>
> Here's a snippet of the code:
>
> ------------
> code.py
> ------------
> import web
> from web import form
>
> render = web.template.render('templates/')
>
> urls = (
>     '/', 'Index'
>     )
>
> class Index:
>     searchbox = form.Form( #define form
>         form.Textbox("search", description="Search")
>         )
>
>     def GET(self):
>         form = self.searchbox() #create copy of form or changes are
> global!
>         return render.index(form)
>     def POST(self):
>         form = self.searchbox()
>         return "value was %s" %(form['search'].value)
>
> -------------------------------
> templates/index.html
> -------------------------------
> $def with (form)
>
> <form name="search" method="post">
>         $:form.render()
> <input type="submit" /> </form>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to