Note that there are some explanatory texts on larger screens.

plurals
  1. PO'unicode' object is not callable
    primarykey
    data
    text
    <p>I'm a web dev. noobie and I'm putting together a simple signup page as practice using Python on GoogleApp Engine. </p> <p>When the signup form is filled out incorrectly, the program works fine. When it's filled out correctly, it's supposed to redirect to a thank you page but instead I get a server error:</p> <pre><code>Internal Server Error The server has either erred or is incapable of performing the requested operation. Traceback (most recent call last): File "/Users/bendavidow/Desktop/Stuff/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEng ine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1547, in __call__ return response(environ, start_response) TypeError: 'unicode' object is not callable </code></pre> <p>My question is two-fold: (1) What does this error mean? and (2) Where is it coming from?</p> <p>Here's the code, minus the html:</p> <pre><code>import webapp2 import re import cgi def escape_html(s): return cgi.escape(s, quote = True) class MainPage(webapp2.RequestHandler): def write_form(self, username = "", email = "", username_error = "", password_error = "", verify_error = "", email_error = ""): self.response.out.write(form %{"username": escape_html(username), "email": escape_html(email), "username_error": username_error, "password_error": password_error, "verify_error": verify_error, "email_error": email_error}) def get(self): self.write_form() def post(self): username = self.request.get('username') password = self.request.get('password') verify = self.request.get('verify') email = self.request.get('email') username_check = re.search(r'^[a-zA-Z0-9_-]{3,20}$', username) password_check = re.search(r'^.{3,20}$', password) email_check = re.search(r'^[\S]+@[\S]+\.[\S]+$',email) username_error, password_error, email_error, verify_error = "", "", "", "" if not username_check: username_error = "Invalid Username" if not password_check: password_error = "Invalid Password" if email != '' and not email_check: email_error = "Invalid Email" if password != verify: verify_error = "Passwords do not match" if username_error or password_error or email_error or verify_error: self.write_form(username, email, username_error, password_error, verify_error, email_error) else: return username self.redirect("/thanks") class ThanksHandler(webapp2.RequestHandler): def get(self): self.response.out.write("Welcome " + username) app = webapp2.WSGIApplication([('/', MainPage), ('/thanks',ThanksHandler)], debug = True) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload