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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:04:35+00:00 2026-06-08T09:04:35+00:00

Ok so I have my apps, that takes requests from root / Almost everything

  • 0

Ok so I have my apps, that takes requests from root / Almost everything is using traversal.

But i’d like to make on top of that site a rest api.

So I’m off with two choices. I either separate the that in two different apps and put that rest application to : rest.site.com, Or I can move it to site.com/rest/*traversal

If I’m doing “/rest/*traversal”, I guess I’ll have to add a route called rest_traversal where the traversal path will be *traversal with the route /rest/*traversal. I did that once for an admin page.

I was wondering if there was a cleanest way to do that. I tried to use virtual_root, but as I understand virtual_root is actually getting added to the path for traversal.

like having virtual_root = /cms and requesting /fun will create the following path /cms/fun

I on the other hand wish to have /cms/fun turned into /fun

  • 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-08T09:04:36+00:00Added an answer on June 8, 2026 at 9:04 am

    If you’re using traversal already, why not just use it to return your “rest API root” object when Pyramid traverses to /rest/? From there, everything will work naturally.

    class ApplicationRoot(object):
    
        def __getitem__(self, name):
            if name == "rest":
                return RestAPIRoot(parent=self, name=name)
            ...
    

    If your “application tree” and “API tree” have the same children and you want to have different views registered for them depending on which branch of the tree the child is located in, you can use containment view predicate to register your API views, so they will only match when the child is inside the “API branch”:

    containment

    This value should be a reference to a Python class or interface that a
    parent object in the context resource’s lineage must provide in order
    for this view to be found and called. The resources in your resource
    tree must be “location-aware” to use this feature.

    If containment is not supplied, the interfaces and classes in the
    lineage are not considered when deciding whether or not to invoke the
    view callable.

    Another approach would be not to build a separate “API tree” but to use your “main” application’s “URI-space” as RESTful API. The only problem with this is that GET and possibly POST request methods are already “taken” on your resources and mapped to your “normal” views which return HTML or consume HTTP form POSTs. There are numerous ways to work around this:

    • register the API views with a separate name, so, say GET /users/123 would return HTML and GET /users/123/json would return a JSON object. Similarly, POST /users/123 would expect HTTP form to be posted and POST /users/123/json would expect JSON. A nice thing about this approach is that you can easily add, say, an XML serializer at GET /users/123/xml.

    • use custom view predicates so GET /users/123 and GET /users/123?format=json are routed to different views. Actually, there’s a built-in request_param predicate for that since Pyramid 1.2

    • use xhr predicate to differentiate requests based on HTTP_X_REQUESTED_WITH header or accept predicate to differentiate on HTTP_ACCEPT header

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

Sidebar

Related Questions

I have 2 apps that I want to make communicate via named pipes on
I have seen several apps that make use of a UISplitViewController inside a tab.
Consider the apps that large blogs have (which work pretty much like an RSS
I have seen many apps that load data to UITableViews from the internet, and
i have a jar file: myServerSide.jar, this jar takes request from client apps, processes
Or something like that. I've upgraded several apps from Rails 3.0 to Rails 3.1.
I have written a simple Google Apps Spreadsheet script that takes details in some
I have two apps that use custom URL schemes to switch between each other.
Say I have two Java apps that I wrote: Ping.jar and Pong.jar and they
I have a website that has one database I have also Desktop apps that

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.