I've done a lot of research trying to solve this problem myself but I am running up short of a solution. If anyone can give me any pointer or help I would really appreciate it.
I am creating a blog that has basic blog functionality such as; likes, dislikes, posts, comments, multiple users, CRUD functions etc. I have so far been able to overcome most of my problems and I am near the completion of this project.
The last bit of trouble I am having is with my Edit Comment functionality, I can delete a comment just fine but if I try to update a comment I got the following error:
ERROR 2017-03-08 14:26:21,907 wsgi.py:279]
Traceback (most recent call last):
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 267, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/home/crow/UdacityProjects/blog/blog.py", line 424, in post
comment.text = self.request.get('comment_text')
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/db/__init__.py", line 617, in __set__
value = self.validate(value)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/db/__init__.py", line 2810, in validate
value = super(UnindexedProperty, self).validate(value)
File "/home/crow/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/db/__init__.py", line 644, in validate
raise BadValueError('Property %s is required' % self.name)
BadValueError: Property text is required
Now I am not exactly sure why this is happening, I looked up the solutions that others were finding for similar problems and none seemed to apply to my situation. Here is my relevant code for reference:
EditComment(BlogHandler)
class EditComment(BlogHandler):
def get(self, post_id, comment_id):
post = Post.get_by_id(int(post_id), parent=blog_key())
comment = Comment.get_by_id(int(comment_id))
if comment:
if comment.user.name == self.user.name:
self.render("editcomment.html", comment_text=comment.text)
else:
error = "You may only edit your own comments"
self.render("editcomment.html", edit_error=error)
else:
error = "This comment no longer exists"
self.render("editcomment.html", edit_error=error)
def post(self, post_id, comment_id):
if self.request.get("update_comment"):
comment = Comment.get_by_id(int(comment_id))
if comment.user.name == self.user.name:
comment.text = self.request.get('comment_text')
comment.put()
time.sleep(0.1)
self.redirect('/post/%s' % str(post_id))
else:
error = "you may only edit your own comments"
self.render(
"editcomment.html",
comment_text=comment.text,
edit_error=error)
elif self.request.get("cancel"):
self.redirect('/post/%s' % str(post_id))
Comment(db.model)
class Comment(db.Model):
user = db.ReferenceProperty(User, required=True)
post = db.ReferenceProperty(Post, required=True)
created = db.DateTimeProperty(auto_now_add=True)
text = db.TextProperty(required=True)
#classmethod
def cdb_blog_id(cls, blog_id):
c = Comment.all().filter('post =', blog_id)
return c.count()
#classmethod
def adb_blog_id(cls, blog_id):
c = Comment.all().filter('post =', blog_id).order('created')
return c
editcomment.html
{% extends "base.html" %}
{% block content %}
<div class="twelve columns">
<h3>Edit Comment</h3>
<hr>
<div class="row">
<div class="twelve columns">
<form method="post">
<label>
<textarea class="u-full-width" name="text" id="texta2">{{comment_text}}</textarea>
</label>
<div class="error">{{edit_error}}</div>
<input type="submit" class="button" name="update_comment" value="Update">
<input type="submit" class="button" name="cancel" value="Cancel">
</form>
</div>
</div>
</div>
{% endblock %}
Now the traceback does not point to the area in my code that is causing the issue so I will provide the relevant lines of the __inti__.py file here:
Line 617
def __set__(self, model_instance, value):
"""Sets the value for this property on the given model instance.
See http://docs.python.org/ref/descriptors.html for a description of
the arguments to this class and what they mean.
"""
value = self.validate(value)
setattr(model_instance, self._attr_name(), value)
Line 2810
raise BadValueError('Property %s must be convertible '
'to a %s instance (%s)' %
(self.name, self.data_type.__name__, err))
value = super(UnindexedProperty, self).validate(value)
if value is not None and not isinstance(value, self.data_type):
raise BadValueError('Property %s must be a %s instance' %
(self.name, self.data_type.__name__))
return value
Line 644
if self.empty(value):
if self.required:
raise BadValueError('Property %s is required' % self.name)
I'm not sure what I'm doing wrong here, and if anyone would be able to offer me any kind of advice I would be very grateful. Thanks again
The error indicates that the value you get from self.request.get('comment_text') and pass to comment.text is invalid - None probably.
The check is done because the text property has the option required set to True in the Comment model.
So check that you properly pass the 'comment_text' request parameter (or its value) around.
Maybe you need name="comment_text" in the following line from editcomment.html?
<textarea class="u-full-width" name="text" id="texta2">{{comment_text}}</textarea>
Related
I'm new to Flask and JS, so I'm really not sure what the problem is here.
app.py
#app.route('/email', methods=["GET", "POST"])
def email():
email_form = EmailForm(csrf_enabled=False)
return render_template("email-form.html", template_form=email_form, action='/appliance2', method='POST')
forms.py (I created that validator using the template from the wtForms docs)
class DBPresenceCheck(object):
def __init__(self, table, message="Field is invalid"):
self.table = table
self.message = message
def __call__(self, form, field):
presence = Connector().query('SELECT 1 FROM %(table)s WHERE %(col_name)s = %(data)s LIMIT 1;',
{'col_name': field.label, 'data': field.data, 'table': self.table})
if presence == 1:
raise ValidationError(self.message)
class EmailForm(FlaskForm):
title = "Enter Household Info"
subtitle = "Please enter your email address:"
email_input = StringField("email", validators=[email(),
DBPresenceCheck('Household', 'That email is already present in the database.')])
# print(email_input.data)
submit = SubmitField("Submit")
email-form.html
{% extends "base.html" %}
{% block content%}
<div class="container py-4">
<div class="p-5 mb-4 bg-light rounded-3">
<h2 class="display-5 fw-bold">{{ template_form.title }}</h2>
<p class="col-md-8 fs-4">{{ template_form.subtitle }}</p>
<form action="{{ action }}" method="{{ method }}">
<div id="main_elements">
{{ template_form['email_input']() }}
</div>
<div id="submit_element">
<br>
{{ template_form["submit"](class_="btn btn-primary") }}
</div>
</form>
</div>
</div>
{%endblock%}
I first realized something was wrong when I was testing the validation, and neither validator ever threw. I added the print statement in forms, and now, when I use flask run, I get the following error.
Traceback (most recent call last):
File "C:\Languages\Python\3.9\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Languages\Python\3.9\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\Scripts\flask.exe\__main__.py", line 7, in <module>
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\flask\cli.py", line 1047, in main
cli.main()
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\flask\cli.py", line 911, in run_command
raise e from None
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\flask\cli.py", line 897, in run_command
app = info.load_app()
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\flask\cli.py", line 312, in load_app
app = locate_app(import_name, None, raise_if_not_found=False)
File "C:\Users\askat\.virtualenvs\askat-YHGTcgZo\lib\site-packages\flask\cli.py", line 218, in locate_app
__import__(module_name)
File "C:\Users\askat\PycharmProjects\cs6400-2022-03-Team060\Phase_3\app.py", line 4, in <module>
from forms import *
File "C:\Users\askat\PycharmProjects\cs6400-2022-03-Team060\Phase_3\forms.py", line 33, in <module>
class EmailForm(AddForm):
File "C:\Users\askat\PycharmProjects\cs6400-2022-03-Team060\Phase_3\forms.py", line 37, in EmailForm
print(email_input.data)
AttributeError: 'UnboundField' object has no attribute 'data'
If the print statement is just print(email_input), then when I run it, the following output
<UnboundField(StringField, ('email',), {'validators': [<wtforms.validators.Email object at 0x0000024145A4F460>, <forms.DBPresenceCheck object at 0x0000024145A4F610>]})>
but no errors are thrown. It seems strange to me that the error is thrown before the field is even created.
In the validators list you need to pass in an instance of class Email. So you field should read:
from wtforms.validators import Email
email_input = StringField("email", validators=[Email(), ...
and don't forget to install the email package as Flask-WTF doesn't include anymore the Email in their validators.
In my code .tpl file:
<form method='post' action='/upload' enctype='multipart/form-data'>
<input type='file' name='newfile'>
<input type='submit' value='Submit'>
</form>
My controller code is:
#app.post('/upload')
def upload():
newfile = request.files.get('newfile')
save_path = os.path.join(config.UPLOAD_DIRECTORY, newfile.filename)
newfile.save(save_path)
return redirect('/')
After browse and submit, I got following 500 error.
Internal Server Error
Exception: AttributeError('save',)
Traceback:
Traceback (most recent call last):
File "/var/www/myproject/bottle.py", line 768, in _handle
return route.call(**args)
File "/var/www/myproject/bottle.py", line 1518, in wrapper
rv = callback(*a, **ka)
File "/var/www/myproject/controllers/index.py", line 753, in upload
newfile.save(save_path)
File "/usr/lib/python2.7/cgi.py", line 521, in __getattr__
raise AttributeError, name
AttributeError: save
Could someone know what this issue is?
Oh I see a problem...
return redirect('/')
Should be:
redirect('/')
That could what is generating your 500 issue.
I'm trying to modify already existing code, simply add form to add photos.
python:
#route('/photos/add')
#jinja_view('add.html')
#post('/photos/add')
def upload_func():
upload = request.files.get('pic')
name, ext = os.path.splitext(upload.filename)
if ext not in ('.png', '.jpg', '.jpeg'):
return "ext is not allowed"
save_path = "/src/photo_gallery/photos"
upload.save(save_path)
return "photo is saved"
HTML:
<form action="/photos/add" method="post">
<div align="center">
<label>Picture</label>
<input type="file" name="pic" required>
</div>
<div>
<label>Info</label>
<input type="text" name="text">
</div>
<div>
<input type="submit" value="add">
</div>
</form>
server log:
Traceback (most recent call last):
File "/home/empty/python/bottle/lib/python3.5/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/home/empty/python/bottle/lib/python3.5/site-packages/bottle.py", line 1740, in wrapper
rv = callback(*a, **ka)
File "/home/empty/python/bottle/lib/python3.5/site-packages/bottle.py", line 3635, in wrapper
result = func(*args, **kwargs)
File "/home/empty/python/bottle/src/photo_gallery/app.py", line 50, in upload_func
name, ext = os.path.splitext(upload.filename)
AttributeError: 'NoneType' object has no attribute 'filename'
127.0.0.1 - - [22/Dec/2016 23:20:42] "GET /photos/add HTTP/1.1" 500 751
You have linked the url path /photos/add to the callback function upload_func. It looks like you want to support two request types (GET and POST), then function decorators should look like this:
#route('/photos/add', method=['GET', 'POST'])
#jinja_view('add.html')
def upload_func():
# ...
Take a look at:
https://bottlepy.org/docs/dev/tutorial.html#request-routing
https://bottlepy.org/docs/dev/api.html#bottle.Bottle.route
Please also note that the code should not be written like this - too complex
I have a small Python app that produces a form, the user enters some strings in and it collects them as an array and adds (or tries to) that array as a value of a key in Google's Memcache.
This is the script:
import webapp2
from google.appengine.api import memcache
MAIN_PAGE_HTML = """\
<html>
<body>
<form action="/get" method="post">
<div><input name="ID"/></div>
<div><input name="param1"/></div>
<div><input name="param2"/></div>
<div><input name="param3"/></div>
<div><input name="param4"/></div>
<div><input name="param5"/></div>
<div><input type="submit" value="Change Status"></div>
</form>
</body>
</html>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(MAIN_PAGE_HTML)
class status(webapp2.RequestHandler):
def post(self):
paramarray= (self.request.get_all('param1'),
self.request.get_all('param2'),
self.request.get_all('param3'),
self.request.get_all('param4'),
self.request.get_all('param5'))
array1 = tuple(paramarray)
memcache.add(key=(self.request.get_all('ID')), value=array1, time=3600)
app = webapp2.WSGIApplication([
('/', MainPage),
('/get', status),
], debug=True)
I've tried setting paramarray as a tuple, not a list. Still getting the same error:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~gtech-iot/1.391041688070473184/main.py", line 41, in post
memcache.add(key=(self.request.get_all('ID')), value=array1, time=3600)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 785, in add
namespace=namespace)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 868, in _set_with_policy
rpc = self._set_multi_async_with_policy(policy, {key: value},
TypeError: unhashable type: 'list'
Tried to set curly braces, regular, squared, with or without the array1=.. statement
Please help,
Thanks
You're passing a list - returned by self.request.get_all('ID') as the key argument to memcache.add(), which is not OK.
I'd suggest some sanity checking of the key - you want it to be at least a non-empty string to make some sense as a memcache key.
If indeed you have multiple possible 'ID' values in the request maybe concatenate them in a string (I'd still question the usability since it's not guaranteed they'd be returned in the same order at the next request) and if not then maybe use self.request.get('ID') instead - it won't return a list like self.request.get_all('ID').
The problem is not with the value (array1) you are storing into Memcache but rather with the key. You cannot use a value of type list as a key. Check Python Memcache API documentaion.
Any method that takes a ‘key’ argument will accept that key as a
string (unicode or not) or a tuple of (hash_value, string) where the
hash_value, normally used for sharding onto a memcache instance, is
instead ignored, as Google App Engine deals with the sharding
transparently.
I have a settings page which has two forms for handling the settings for two different Models. The Profile model form works. The Chef model form doesn't. The form fails gracefully, and isn't throwing a Django error page - so in using pdb, I found the form is not valid, and is throwing a Syntax Error.
I'm confused as to which field this error is coming form. Any help would be greatly appreciated. Thanks!
Error:
*** SyntaxError: SyntaxError('unexpected EOF while parsing', ('<string>', 0, 0, ''))
HTML
{% if form.is_multipart %}
<form enctype="multipart/form-data" method="post" action=".">{% csrf_token %}
{% else %}
<h3>Profile Settings</h3>
<form method="post" action=".">
{% endif %}
<dl>
<dt>{{form.photo.label}}</dt>
<dd>{{form.photo}}</dd>
<dt>{{form.firstname.label}}</dt>
<dd>{{form.firstname}}</dd>
<dt>{{form.lastinitial.label}}</dt>
<dd>{{form.lastinitial}}</dd>
</dl>
<button type="submit">Save</button>
</form>
<h3>Chef Settings</h3>
<form action="{% url edit_chef chef.id %}" method="post" accept-charset="utf-8">{% csrf_token %}
<dl>
<dt>{{chefform.category.label}}</dt>
<dd>{{chefform.category}}</dd>
<dt>{{chefform.price.label}}</dt>
<dd>{{chefform.price}}</dd>
<dt>{{chefform.meal.label}}</dt>
<dd>{{chefform.meal}}</dd>
<dt>{{chefform.language.label}}</dt>
<dd>{{chefform.language}}</dd>
<dt>{{chefform.address.label}}</dt>
<dd>{{chefform.address}}</dd>
<dt>{{chefform.neighborhood.label}}</dt>
<dd>{{chefform.neighborhood}}</dd>
<dt>{{chefform.city.label}}</dt>
<dd>{{chefform.city}}</dd>
<dt>{{chefform.state.label}}</dt>
<dd>{{chefform.state}}</dd>
<dt>{{chefform.menu.label}}<span id="rBann" class="minitext">1000</span></dt>
<dd>{{chefform.menu}}</dd>
</dl>
<button type="submit">Save</button>
</form>
Chef Form
class ChefForm(forms.ModelForm):
class Meta:
model = Chef
fields = ('category','meal','price','language','address','neighborhood','city','state', 'country', 'menu')
category = forms.ChoiceField(
label=_("Food style"),
choices=([('Afghan','Afghan'),('African','African'),('American','American'),]),
required=True)
meal = forms.ModelMultipleChoiceField(
label=_("What is your best meal?"),
queryset=Meal.objects.all(),
required=True)
price = forms.IntegerField(
label=_("Price per person"),
widget=forms.TextInput(),
required=True)
language = forms.ModelMultipleChoiceField(
label=_("Languages spoken"),
queryset=Language.objects.all(),
required=True)
address = forms.CharField(
label=_("Your Address"),
widget=forms.TextInput(),
required=True)
neighborhood = forms.CharField(
label=_("Your Neighborhood"),
widget=forms.TextInput(),
required=True)
city = forms.CharField(
label=_("Your City"),
widget=forms.TextInput(),
required=True)
state = forms.CharField(
label=_("Your state"),
widget=forms.TextInput(),
required=True)
country = forms.CharField(
label=_("Your country"),
widget=forms.TextInput(),
required=True)
menu = forms.CharField(
label=_("What's unique about your cooking & home? Pets? Have a family or roommates?"),
widget=forms.TextInput(),
required=True)
def __init__(self, *args, **kwargs):
super(ChefForm, self).__init__(*args, **kwargs)
self.fields['price'].widget.attrs = {
'placeholder':'10'}
self.fields['menu'].widget.attrs = {
'placeholder':'Tacos!'}
View:
#login_required
def edit_chef(request, chef_id, template_name="chef/newchef.html"):
chef = get_object_or_404(Chef, id=chef_id)
if request.user != chef.cook:
return HttpResponseForbidden()
if request.method == 'POST':
import pdb; pdb.set_trace()
chefform = ChefForm(request.POST, instance=chef)
if chefform.is_valid():
chefform.save()
return HttpResponseRedirect('/users/%d/' % request.user.id)
else:
return HttpResponseRedirect('/users/%d/' % request.user.id)
data = { "chef":chef,
"chefform":chefform }
return render_to_response(template_name,
data,
context_instance=RequestContext(request))
To add more information to this bug, I was able to pull up this broken pipe error:
[29/Jan/2011 09:20:24] "POST /chef/1/edit/ HTTP/1.1" 200 104804
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 281, in run
self.finish_response()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 321, in finish_response
self.write(data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 400, in write
self.send_headers()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 464, in send_headers
self.send_preamble()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 382, in send_preamble
'Date: %s\r\n' % http_date()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 322, in write
self.flush()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53340)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 562, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------
[29/Jan/2011 09:20:27] "GET /users/2/ HTTP/1.1" 200 114593
SyntaxError::SyntaxError comes from the Python parser itself. I don't think this has anything to do with your form data.
I'd try running pylint, pyflakes or pep8 compliance on this code and see what it says.
I'm suspecting an error parsing one of your Python files, possibly some part of one of the files that's shown above, but not exactly what you have there. For example, a stray ( or [ or { character somewhere might cause this kind of problem, since the Form code isn't executed until called.
The odd indentation on your "required=True" parts of the ChefForm declaration support this guess. Your editor is indenting incorrectly because of some issue, likely above the entire declaration of "class ChefForm" that we can't see here.
EDIT: sorry I'm mistaken with my last reply. I was thinking of something else.
replace the %s with %d on this line:
return HttpResponseRedirect('/users/%s' % request.user.id)