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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:16:26+00:00 2026-05-27T10:16:26+00:00

I need to pass a subpath as a param in a route generated by

  • 0

I need to pass a subpath as a param in a route generated by Pyramid. I tried using urllib.encode and urllib.quote but get a “resource could not be found error” either way.

route generation:

mypath='a/b/c'
new_route = route_url('new_model_route', self.request, subpath=urllib.encode(mypath))

my route:

config.add_route('new_model_route', '/model/new/{subpath}')

generated url (with “resource not found error”)

http://127.0.0.1:6544/rnd2/model/new/a%2Fb%2Fc

I know it has to do with the escaping because the url http://blah/model/new/a works.

  • 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-27T10:16:27+00:00Added an answer on May 27, 2026 at 10:16 am

    The route pattern /model/new/{subpath} would never match /model/new/a/b/c so I don’t understand why you would be able to generate a URL for that pattern?

    It is possible to pass the rest of the url as elements, however.

    config.add_route('new_model_route', '/model/new/{subpath}')
    request.route_url('new_model_route', 'b', 'c', subpath='a')
    # /model/new/a/b/c
    

    On the other hand, you have another option. You can create a new route to match these urls, such as:

    config.add_route('new_model_route', '/model/new/*subpath')
    # matches /model/new/a, /model/new/a/b, etc
    
    request.route_url('new_model_route', subpath=('a', 'b', 'c'))
    # /model/new/a/b/c
    

    If you didn’t actually want to match these URLs for some reason, you can add static=True to the add_route call, which means that you are only using the route name to generate urls but not to match them on incoming requests.

    subpath and traverse happen to be special (this is all documented) but if you were hellbent on using ‘a/b/c’ you could use something else in the route pattern:

    config.add_route('new_model_route', '/model/new/*rest')
    # matches /model/new/a, /model/new/a/b, etc
    
    request.route_url('new_model_route', rest='a/b/c')
    # /model/new/a/b/c
    

    Oh and since I’m on a roll, you can use the original approach with a simpler url which you may already have in your system.

    config.add_route('new_model_route', '/model/new')
    # matches /model/new only
    
    request.route_url('new_model_route', 'a', 'b', 'c')
    # /model/new/a/b/c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass the $route to its inner function,but failed: function compilePath( $route
I need to pass input values to the db using ajax and php but
I need to pass configuration settings to an AddIn created using the Managed AddIn
I need to pass a char * to a function, but this function really
I'm using SmartPart 1.3 to develop web-parts to SharePoint. I need pass parameter to
Need to pass get parameter without value and without = symbol to utilize external
I need to pass a List of Types to a method, but I want
I need to pass javascript date value to vb.net function. Method iam using now:
I need to pass exceptions across a thread boundary. I'm using python embedded in
I need to pass char* to XPCOM function but that function accepts PRUnichar *

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.