Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6928159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:08:53+00:00 2026-05-27T11:08:53+00:00

In Tornado, you can link Regexes to RequestHandlers. The matched groups from the Regexes

  • 0

In Tornado, you can link Regexes to RequestHandlers. The matched groups from the Regexes get passed into the RequestHandler’s get() or post() method as arguments.

The problem is, I want to read the values of these matched groups before the get() or post() is called. Does Tornado have a way of accessing these matched groups outside of get() or post()? I want something analogous to RequestHandler.arguments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:08:54+00:00Added an answer on May 27, 2026 at 11:08 am

    Unfortunately, there does not seem to be a way to access the url regex match from “prepare”.

    Looking at the code in tornado/web.py, especially line 949, prepare is called without parameters at all.

    I’ve hacked together a solution, that works, but it’s not robust at all… Here it is.

    import tornado.ioloop
    import tornado.web
    from tornado import escape
    
    class MainHandler(tornado.web.RequestHandler):
        def prepare(self):
            # work out url regex match as in
            # tornado/web.py:1283
            handlers = self.application._get_host_handlers(self.request)
            for spec in handlers:
                match = spec.regex.match(self.request.path)
                def unquote(s):
                    if s is None: return s
                    return escape.url_unescape(s, encoding=None)
                args = [unquote(s) for s in match.groups()]
                # do something with args
    
        def get(self, who):
            self.write('hello ' + who)
    
    if __name__ == "__main__":
        application = tornado.web.Application([
            (r"/(\w+)", MainHandler),
        ])
        application.listen(8999)
        tornado.ioloop.IOLoop.instance().start()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the post method of a RequestHandler in Tornado, self.get_argument(arg, None) gets the value
I can't seem to get my app to accept POST requests from a different
The HTTPRequest class in the tornado* web framework helpfully maps GET and POST arguments
I am using Tornado and I have the following code: class UserHandler(RequestHandler): def get(self):
Tornado web framework seems to expose a method RequestHandler.prepare() which is called before the
In Tornado, you can do if statements in the HTML such as {% if
I'm writing a tornado web server and I'm trying to keep it from blocking
I have a simple form using a POST method, consisting of a text box
I have a simple tornado server running like this: import json import suds from
am sorry for that question, am beginning in Tornado, and because i come from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.