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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:32:57+00:00 2026-05-31T12:32:57+00:00

Having understood Traversal and the whole resource and context concepts from my question ,

  • 0

Having understood Traversal and the whole resource and context concepts from my question, I tried some tutorial examples that played with the Hybrid routing as stated in the documentation. I kind of understand it if not for some minor problems:

If I were to traverse the following URL: http://example.com/product/123/edit with the following add_route configuration:

config = Configurator(settings=**settings, root_factory=RootFactory)
config.add_route('product_edit', '/product/{pid}/edit', factory=ProductFactory, traverse='/{pid}/edit')

config.add_view(route_name='product_edit', name='edit', renderer='edit.mako')
  1. Does it mean that when I supply a product factory to the add_route function, the root resource factory is changed to the product factory (hence product factory is now the new Root resource)?

  2. If the root resource is indeed changed to the ProductFactory for traversal, what would I set the __parent__ & __name__ attributes of the ProductFactory to? Because it looks like the __parent__ will be None, am I correct?

Here’s my ProductFactory code:

class ProductFactory(object):
    __name__ = 'product'
    __parent__ = None

    def __getitem__(self, key):
        if key.isnumber():
            try:
                p = sess_.query(model.Product).filter(pid=key).one()
            except:
                raise DBException()
            if p:
                return p
            else:
                return KeyError
  • 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-31T12:32:58+00:00Added an answer on May 31, 2026 at 12:32 pm

    the “factory” param tells pyramid to use that to determine the context(and indirectly the acl) for that route.

    root resources by definition do not have a parent. so parent would indeed be none. Now looking at your code, I’m not sure it would work but this should accomplish what you want.

    config = Configurator(settings=**settings, root_factory=RootFactory)
    config.add_route('product_edit', '/product/*traverse', factory=ProductFactory)
    
    config.add_view(route_name='product_edit', name='edit', renderer='edit.mako', context=model.Product)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some little issues pulling data from Twitter. Basically I am building a
I'm having trouble with something that I understand should function out of the box
I'm starting to understand git but I'm still having some trouble with the abstraction.
I am having a hard time understanding the nuances of git-fetch. I understand that
I am having some trouble understanding the MVC Pattern. I do understand we are
I need some help at understanding how foreign keys and cascades work. I understood
We're about to set off our first larger WCF project, and we're having some
Having (presumably) understood the motivation behind Nuget, I want to know, whether we still
I am having trouble with Paypal IPN About one thing, As I understood, paypal
I'm having a blackout here. I thought I understood these principles, but I can't

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.