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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:50:17+00:00 2026-05-27T21:50:17+00:00

Is there a way to pass an extra parameter at the level of the

  • 0

Is there a way to pass an extra parameter at the level of the @view_config level?

I would like to use multiple @view_config decorators for a method but pass a parameter to indicate which one has been used:

@view_config(renderer="shape.mak", route_name='circle_route')
@view_config(renderer="shape.mak", route_name='triangle route')
def new_model(self, fparams=None, ppath=None):
    #here, I'd like to capture a variable that tells me whether the cirlce or triangle route was used to access this method

I realize I can consolidate my routes (eg have a shape route) and add an extra parameter for the type of shape, but I’d like to know my options.

  • 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-27T21:50:17+00:00Added an answer on May 27, 2026 at 9:50 pm

    The view configuration is intended to be declarative. This means the view doesn’t know how it’s being rendered, you just return the same dictionary format each time and the chosen renderer will handle it based on predicates. That being said, you can break this pattern if you wish because you can do whatever you want to in a custom_predicate.

    def set_shape_predicate(shape):
        def predicate(context, request):
            request.shape = shape
            return True
        return predicate
    
    @view_config(renderer="shape.mak", route_name='circle_route', custom_predicates=[set_shape_predicate('circle')])
    @view_config(renderer="shape.mak", route_name='triangle route', custom_predicates=[set_shape_predicate('triangle')])
    def new_model(self):
        # request.shape will be 'circle' or 'triangle'
    

    You could also just check request.matched_route.name and compare it to each of the route names ('circle_route' or 'triangle_route') in a url dispatch scenario.

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

Sidebar

Related Questions

Is there a way to pass some extra parameter to the function that is
Is there a way to pass a null value to a parameter in C#?
Is there a way to pass a piece of extra data along with a
Is there a way to pass results generated within a PHP page (called into
Is there any way to pass HTTP AUTH username and password along with an
Is there any way to pass command line parameters to a Flash projector in
Is there any way to pass a callback to java code, from C. And
Is there a way to pass foo_ around outside of main? I saw something
Is there a way to pass a variable into a regex in jQuery/Javascript? I
Is there a way to pass a class into a property as a Class

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.