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 8862957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:51:21+00:00 2026-06-14T15:51:21+00:00

I am using a route like the following in my app: Route(r’/thing/<some_id>/foo’, handler=ThingFoo, name=thing-foo)

  • 0

I am using a route like the following in my app:

Route(r'/thing/<some_id>/foo', handler=ThingFoo, name="thing-foo")

This is used to generate a url using uri_for('thing-foo', some_id="something"), which is returned to the user which they store.
Then, in another request, the user posts the url returned to them previously, where it needs to be parsed.

I would like to extract the <some_id> pattern’s value from the url provided in a similar way to how the router does it to pass the value to the RequestHandler’s get/post methods, but the documentation on this seems to be lacking.

Is there something like the following?

route, some_id = webapp2.extract_uri(the_url)

(Of course I could extract the value directly using a regex, but that doesn’t seem very DRY).

Here is an example of what I want to do.

def image_url(request, image_blob_key):
    if image_blob_key:
        return request.url_for('image', resource=image_blob_key, _full=True)
    else:
        return None

def blob_key_from_image_url(image_url):
    # Do something here to calculate the blob_key from the URL.
    return blob_key

In one part of my app, image_url is calculated from a blob_key and passed to the user. Later on if they (for example) want to delete the image, they pass the url back in a POST request, and I want to extract the blob_key from it so I can delete it.

  • 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-14T15:51:22+00:00Added an answer on June 14, 2026 at 3:51 pm

    Maybe something like this will work for you:

    import webapp2
    
    # somewhere in a request handler:
    route = self.app.router.build_routes.get('my-route-name')
    match = route.regex.match(the_url)
    args, kwargs = webapp2._get_route_variables(match, route.defaults.copy())
    
    # do something with args and kwargs, e.g. 
    # thing = kwargs['thing-foo']
    

    Source code: http://webapp-improved.appspot.com/_modules/webapp2.html#Route

    To be honest, I would simply pass blob_key to the template where users can delete an image, so that I could just build a URL beforehand, e.g.

    uri_for('delete-image', image_key=some_blob_key)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I'm using the following route handler to route urls in a .net 4.0 solution.
I've added a resource route to my app using - resources :cars I've used
I have the following problem: For example I have route like this: routes.Add(new Route(forums/thread/{threadOid}/last,
When we define routes in routes.rb using the name like map.some_link .We can use
using the default route routes.MapRoute( Admin, // Route name Admin/{action}, // URL with parameters
I'm developing web app using Spring Integration to route my messages, but I have
In a Mojolicious app I have a route in my Controller code like the
I have noticed when one creates a project using Express.js, the route handler functions
I am implementing a like system in my rails app using David Celis gem

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.