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

  • Home
  • SEARCH
  • 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 9185477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:17:10+00:00 2026-06-17T19:17:10+00:00

I have the following hook in BottlePy : @bottle_app.hook(‘before_request’) def update_session(): # do stuff

  • 0

I have the following hook in BottlePy:

@bottle_app.hook('before_request')
def update_session():
    # do stuff
    return

And some routes:

@bottle_app.route('/')
def index():
    return render('index')

@bottle_app.route('/example')
def example():
    return render('example')

From within update_session(), how can I determine which route is being called?

I have looked through the documentation to no avail, but surely this is possible?

  • 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-06-17T19:17:12+00:00Added an answer on June 17, 2026 at 7:17 pm

    The request has both a bottle.route and a route.handle entry, both contain the same value:

    from bottle import request
    
    print request['bottle.route']
    

    This isn’t documented; I had to find it in the bottle.py source. The value is a Route instance; it has both a .name and a .rule attribute you could inspect to determine which route was matched.

    if request['bottle.route'].rule == '/':
        # matched the `/` route.
    

    For your specific example this is perhaps overkill, since you are only matching simple paths, but for more complex rules with regular expression rules this would work better than trying to match the request.path attribute (but it’d be a good idea to give your routes a name value).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been following the post below trying to hook my SubVersion installation to
I have the following pre-commit hook to use JavaScript Lint for checking JavaScript files
Say I have the following link: <li class=hook> <a href=i_have_underscores>I_have_underscores</a> </li> How would I,
I have created the following git hook to update my web application when new
I have the following post-receive hook I wrote on a virtual server such that
I have the following code: (ns test-hook.core) (defn -main [] (.addShutdownHook (Runtime/getRuntime) (Thread. #(println
I have the following elements defined in my form hook: $form['touchpointdivision'] = array( '#type'
I have the following code in a git post-update hook that cd 's into
I have the following XML file (below) and i'd like to get a hook
I have the following class in PHP5.3: class MyClass { public $a=1; public $hook;

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.