Just tried submitting to a form as POST via jQuery with the following
parameters:
productId=bbf156e&attributeId=423e002&value=
If there's a space as "value", things work as expected. But if there's
no space, I get a warning on the Tornado side, and a 404 on the
client:
404 POST /product/setAttribute (127.0.0.1): Missing argument value
This is the bit of code that's doing it:
class ProductSetAttributeHandler(tornado.web.RequestHandler):
def post(self):
product_id = self.get_argument("productId")
attribute_id = self.get_argument("attributeId")
value = self.get_argument("value")
Is there something I can do to get value to come up as an empty string
instead of 404ing?
Thanks!
product_id = self.get_argument("productId") or ''
On Fri, Apr 9, 2010 at 3:11 PM, Chris <partyo...@gmail.com> wrote:
> value = self.get_argument("value")
--
Saygılar && İyi Çalışmalar
Timu EREN ( a.k.a selam )
--
To unsubscribe, reply using "remove me" as the subject.
http://github.com/facebook/tornado/blob/master/tornado/httpserver.py#L393
arguments = cgi.parse_qs(query)
cgi.parse_qs (now urllib.parse_qs) has a parameter called
keep_blank_values, which we're not using.
http://docs.python.org/library/cgi.html#cgi.parse_qs
Would it makes sense to patch to httpserver to keep blanks?
On Apr 9, 2:11 pm, "David Timothy Strauss" <da...@fourkitchens.com>
wrote:
Patching might be fine but it would run the risk a breaking user code
which has a dependency on blank parameters being equivalent to non-
existent parameters when using self.get_argument.
The way I worked around the issue in my handler was to use the
underlying request object and call cgi.parse_qs myself with the
keep_blank_values set to True and that seems to work ok.
On Apr 9, 10:10 pm, Chris <partyonais...@gmail.com> wrote:
> I wasn't able to find a place in the HTTP spec about blank elements,
> but I did dig further into Tornado and find out where the blanks are
> being handled.
>
> http://github.com/facebook/tornado/blob/master/tornado/httpserver.py#...
If blank POST parameters are allowed by the HTTP spec, then from the
principle of least surprise it would arguably make sense to have them
fall through in Tornado too. (Maybe not in this version but in a major
release...)
I think I'll use your workaround for now and let the core team decide
whether/when my patch is worthy.