How to separate parameters in url-query and post-data in tornado.web.RequestHandler.get_arguments?

1,236 views
Skip to first unread message

mission liao

unread,
Jul 19, 2013, 5:31:47 AM7/19/13
to python-...@googlegroups.com
Hi,

  It seems RequestHandler would map both url-query and post-data to RequestHandler.arguments.
  For example:


  With a form in this page:

      <form method="post">
      <input type="text", myname="myname">
      ....

  Once this form submitted with typing "tom" in the textfield, both "tom" and "qoo" would apear in RequestHandler.request.arguments.


  I know it's a weird use case but I wonder why tornado merge these datum to one place but not just place them in separated variables.

Regards,
Mission.

Didip Kerabat

unread,
Jul 19, 2013, 11:55:39 AM7/19/13
to python-...@googlegroups.com
Can't you just get the full URL from request object and parse your GET params that way?

It's usually a bad design to have random GET params as part of POST request.

Didip Kerabat
Co-founder of ontheplates.com
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

aliane abdelouahab

unread,
Jul 19, 2013, 1:42:14 PM7/19/13
to python-...@googlegroups.com
you are mixing get and post
in post you will not find the variables in url, in get you will see them
if you want to not use post, and retrieve the variable from the url, use regular expression, that's what i did here:
i've used this technique to split the number of the results without passing the  parameters to not being changed by the user and hack the system.

Ben Darnell

unread,
Jul 20, 2013, 1:14:44 PM7/20/13
to Tornado Mailing List
Tornado merges query and post-body arguments because in general it's more useful to be able to handle both styles of form submission in the same way than to support the rare case where you need to make a distinction between them.  You can re-parse the query or body if you have to, although it would be nice if tornado stored the parsed results separately so you didn't have to.  What is your use case for this?  Would attributes on HTTPRequest similar to request.arguments be enough or would you want parallel versions of the higher level get_argument API?

-Ben

mission liao

unread,
Aug 20, 2013, 12:00:59 PM8/20/13
to python-...@googlegroups.com, b...@bendarnell.com
Hi,

   Actually I'm just curious about the concept behind this design. Thanks for replying.

Ben Darnell於 2013年7月21日星期日UTC+8上午1時14分44秒寫道:
Reply all
Reply to author
Forward
0 new messages