Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6793935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:09:40+00:00 2026-05-26T18:09:40+00:00

Hi how can I get the variables in a HTTP post with WTForms when

  • 0

Hi how can I get the variables in a HTTP post with WTForms when the post is done with a blobstoreuploadhandler and preferably also with i18n localized messages for validation?
This is my code that is not working:

class AdForm(Form):
    name = TextField(_('Name'))
    title = TextField(_('title'))
    text = TextAreaField(_('Text'),widget=TextArea())
    phonenumber = TextField(_('Phone number'))
    phonenumberhide = BooleanField(_('Display phone number on site'))
    price = TextField(_('Price'))
    password = PasswordField(_('Password'))
    email = TextField(_('Email'))

When I try to access the data posted via the form the data turns out as None:

form = AdForm(data=self.request.POST)
if form.title:
  logging.info('getting title:'+form.title.data)
  ad.title = form.title.data
  ad.save()

The above does not save anything to the datastore and this is the template where it’s coming from

  <div class="labelform">
         <div class="labelform" style="clear:left;">
    <label> {% filter capitalize %}{% trans %}title{% endtrans %}{% endfilter %}:</label>
  </div>
  </div>
  </td><td>
{{ form.title }}{% if form.title.errors %}
        <ul class="errors">{% for error in form.title.errors %}<li>{{ error }}</li>{% endfor %}</ul>
    {% endif %}

Can you help me? There’s something in the WTForms manual about appengine but I couldn’t find a working example.

Update

I added validation tests and I still can’t access the variables:

logging.info('getting requests')
if form.validate():
  if form.title:
    logging.info('getting title:'+form.title.data)
    ad.title = form.title.data
    ad.save()
    ad.put()

Logging output:

INFO 2011-11-05 23:17:24,653 main.py:1504] getting requests INFO
2011-11-05 23:17:24,653 main.py:1507] getting title:

Update 2

I removed the WTForms dependence and it is still not working. The line logging.info('getting data:'+ self.request.get('title', '0')) only outputs 0 even though the form is just a regular http post form:

 <form action="{{form_url}}" name="upload" method="post" enctype="multipart/form-data" accept-charset="utf-8">

Update 3

This minimal config with no WTForms and no Jinja works so it’s probably something with Jinja when this bare-bones example works with webapp2 and python 2.7 where I’m going to add the faulty code line by line to troubleshoot:

class GuestPage(BaseHandler):
    def get(self):
        self.response.out.write("""
          <html>
            <body>
              <form action="/sign" method="post">
                <div><textarea name="content" rows="3" cols="60"></textarea></div>
                <div><input type="submit" value="Sign Guestbook"></div>
              </form>
            </body>
          </html>""")


class Guestbook(BaseHandler, I18NHandler, blobstore_handlers.BlobstoreUploadHandler):
    csrf_protect = False

    def post(self):
        self.response.out.write('<html><body>You wrote:<pre>')
        self.response.out.write(self.request.get('content'))
        self.response.out.write('</pre></body></html>')


app = webapp2.WSGIApplication([        ('/guest', GuestPage),
                                      ('/sign', Guestbook),

…

Update 4

My back to basics is working with Jinja so I suppose I just build on this example and see where it breaks:

class GuestPage(BaseHandler):
    def get(self):
    self.render_jinja('form_jinja')

class Guestbook(BaseHandler, I18NHandler, blobstore_handlers.BlobstoreUploadHandler):
    csrf_protect = False

    def post(self):
        self.response.out.write('<html><body>You wrote:<pre>')
        self.response.out.write(self.request.get('content'))
        self.response.out.write('</pre></body></html>')

Update 5

I can reproduce the error with this minimal example that can’t access the http post variable:

class GuestPage(webapp2.RequestHandler):
    def get(self):

        self.response.out.write("""
          <html>
            <body>
              <form action=" """ +blobstore.create_upload_url('/sign')+ """ " method="post">
                <div><textarea name="content" rows="3" cols="60"></textarea></div>
                <div><input type="submit" value="Sign Guestbook"></div>
              </form>
            </body>
          </html>""")


class Guestbook(blobstore_handlers.BlobstoreUploadHandler):

    def post(self):
        self.response.out.write('<html><body>You wrote:<pre>')
        self.response.out.write(self.request.get('content'))
        self.response.out.write('</pre></body></html>')


app = webapp2.WSGIApplication([       ('/guest', GuestPage),
                                      ('/sign', Guestbook),

Update 6

From the guestbook example code with blobstoreuploadhandler I can upload a file on the production server so I could make a working example that uses the blobstoreuploadhandler that I will try to build on for my use case.

Update 7

I could get my original code so that everything works except the blob transfer. I suspect a diff between dev_appserver and production that I posted to the google appengine group about. We’ll see how it progresses.

Update 8
Here’s another common use how nothing works when you add WTForms:

    logging.info('getting data:'+ self.request.get('title', '0'))
    logging.info('http post data:'+ str(self.request.post))
    form = AdForm(formdata=self.request.data)
    logging.info('populated form')
    logging.info('form data:' + str(form.formdata))
    if form.validate():
      if form.title:
        logging.info('getting title:'+str( form.get('title') ) )
        ad.title = form.title.data      ad.save()       ad.put()
      if form.text:
        logging.info('getting text:' +str(form.text))
        ad.text = form.text.data
      if self.request.get('currency'):
        ad.currency = self.request.get('currency')
      if self.request.get('cg'):
        ad.category = form.cg.data
      if self.request.get('company_ad') == '1':
        ad.company_ad = True
      ad.put()
    else:
      logging.info('form did not validate')
except Exception, ex:
    logging.info('there occured exception %s', str(ex))

INFO 2011-11-09 12:11:50,868 main.py:1385] getting data:TEST INFO
2011-11-09 12:11:50,868 main.py:1409] there occured exception post

Update 9

Finally the form populates it just doesn’t validate. Thank you Sean for the info that got me further. Now I get past populated the form object with no exception but the exception occurs when I try to validate:

logging.info('getting data:'+ self.request.get('title', '0'))
form = AForm(self.request.POST)
logging.info('populated form')
if form.validate():
  logging.info('validated form')

The above code is logging the output:

INFO     2011-11-11 08:03:59,913 main.py:1387] getting data:TEST
INFO     2011-11-11 08:03:59,914 main.py:1390] populated form
INFO     2011-11-11 08:03:59,914 main.py:1412] there occured exception 'builtin_function_or_method' object is not iterable

What does the exception mean?

My form class is

class AForm(Form):
    name = TextField(_('Name'))
    title = TextField(_('title'))
    text = TextAreaField(_('Text'),widget=TextArea())
    phonenumber = TextField(_('Phone number'))
    phonenumberhide = BooleanField(_('Display phone number on site'))
    price = TextField(_('Price'))
    password = PasswordField(_('Password'))
    email = TextField(_('Email'))  
    category  = SelectField(choices=categories.keys)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:09:41+00:00Added an answer on May 26, 2026 at 6:09 pm

    I don’t know anything about WTForm, but I’d guess that like Django forms, you need to call the validation function before you can access the data. In this case, it’s form.validate():

    form = AdForm(formdata=self.request.POST)
    if form.validate():
        ad.title = form.title.data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get Environnment variables and if something is missing, set the value?
I've played around quite a bit now, and can't seem to get variables to
Possible Duplicate: How can I get a list of all the defined variables in
I can't figure out how to get the SCOPE_IDENTITY() back to my variables from
I'm trying to access a member structs variables, but I can't seem to get
Given this variable in tcsh: set i = ~/foo/bar.c how can I get just
Can I get some help on how to submit a POST with the necessary
How can I save image with PHP which was uploaded with http post using
I have a couple of functions that perform HTTP POST/GET/HEAD requests. For the POST
I have an HTTP POST request with the following variables: UnicodeMultiDict: ... (u'ids[]', u'568236498'),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.