Help! How tornado to get arguments?

10,392 views
Skip to first unread message

HENG

unread,
Sep 20, 2010, 1:24:15 AM9/20/10
to python-tornado
Hello:

I know the method self.get_argument() , but, I also has some problems as follows:

1. if I have an URL like this www.example.com/login?refer=value1&server=value2&action=add . OK.
Now, I want get the keys: refer, server, action, How can I do that?
And more, How can I handler those values in the RequestHandler?

I have try this, but it doesnot work:

handler = [(r"/login", LoginHandler)]  # I do not how write the regxp of Url_spec

class LoginHandler(BaseRequestHandler):
    def get(self):
        refer = self.get_argument("refer", None)


2. if I have an URL like this www.example.com/user/{{ User-Name }} ?action=editemail, and {{ User-Name }} means ANY words
as abcdefg.
OK, Now, I want to get the {{ User-Name }}  in my Handler, and as the Problem 1, how can I

And more, I have read the source code in the demo named blog, but I do not know how to pass the value after ?, which is ?action=editemail

this is my code example:

handler = [(r"/user/(/.+)", UserHandler)]

class UserHandler(BaseRequestHandler):

    def get(self, username): 
# Now the {{ User-Name }} pass to Here

        actiion = self.get_argument("action", None)
   # It do Not work


I really need a Tornado's Document in detail. It is really import thing to a new guy that is new Tornado.

I like Tornado more than Django, Django is convenient but its source code is hard to read to me. Tornado
is just simple and brief to understand, this is the reason I choise it. but sometimes I must pay for my choise,
because Tornado's code samples are too little and Now I must ask some stupid questions in the mail list.

I hope Tornado will have a document in detail, and I do not need to read the source code to find out how to
get the User-Agent  by the method self.request.headers["User-Agent"] . Not all will want to read the source
code and A document in detail is needed for the new, even it seems to waste a lot of  time, especially to our Good
guys have write Python  some years.

OK, in the end, I want to say, I am not a pythonic code geek, I just have a computer and just want to write some
code for fun. HAHA.



--
--------------------------------------------------------------------
HengZhou
---------------------------------------------------------------------
--

Felinx Lee

unread,
Sep 20, 2010, 1:36:48 AM9/20/10
to python-...@googlegroups.com
It should be worked, you can print self.request.arguments in a handler to see all of arguments, maybe you have some typos.
--
Felinx Lee

What powered sites?
http://poweredsites.org

What can change the nature of a man?(Planescape Torment)
http://en.wikipedia.org/wiki/Planescape:_Torment

ABHISHEK TAILOR

unread,
Jun 1, 2019, 3:12:29 AM6/1/19
to Tornado Web Server
the method self.get_argument() gets data from the body not from params.

Rajdeep Rath

unread,
Jun 1, 2019, 6:25:08 AM6/1/19
to python-...@googlegroups.com
I use this to extract Parameters:

token = handler.get_argument("token", None, True)

Works fine with get or post !

For url pattern matching search in stackoverflow there are lots of answers.


If you want help with a specific pattern, post there. 




--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-tornado/e98ee741-f862-4d2d-86bf-fe85cb16ef5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages