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

  • Home
  • SEARCH
  • 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 6936057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:11:05+00:00 2026-05-27T12:11:05+00:00

I am attempting to implement a pattern where I use an intermediate function to

  • 0

I am attempting to implement a pattern where I use an intermediate function to determine which function to call and have the final function do the rendering, but the flow does not end up rendering. What am I missing? Is there a way to tweak this to make it work?

Here’s what I’m attempting.

@view_config(route='fork_route')
def fork(self):
    x = True
    if x:
        self.my_func1
    else:
        self.my_func2
    #I expected it to render before this point
    return dict({'msg':'failed'})

@view_config(renderer="templates/derived/template1")
def my_func1:
    return dict({'msg':'msg1'})

@view_config(renderer="templates/derived/template2")
def my_func2:
    return dict({'msg':'msg2'})
  • 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-27T12:11:05+00:00Added an answer on May 27, 2026 at 12:11 pm

    Pyramid’s renderers are pretty simple, and in the end it’s “just python”. Meaning you’re calling functions from functions, nothing special.

    The way Pyramid’s automated rendering works is:

    1. Request comes in, gets dispatched to a view.
    2. If that specific view view does NOT return a Response object, then Pyramid attempts to pass the value you returned from the view into the attached renderer.

    The view_config is only relevant to the current request’s view. The other functions you are calling are simply functions in Python.

    If you still want to delegate the work to another view then there are several options, but the one we tell people is that you will need to explicitly call pyramid.renderers.render within the sub-view or render_to_response. Of course if you only call render then you must turn that html body into a full Response object.

    def fork(request):
        return myfunc1(request)
    
    def myfunc1(request):
        return render_to_response('templates/derived/template2', {'msg': 'msg1'}, request)
    

    Notice how myfunc1 returns a Response object so fork (the view that is active for this request) can just return it.

    Otherwise you need to turn the result into a response:

    def fork(request):
        resp = request.response
        resp.body = myfunc1(request)
        return resp
    
    def myfunc1(request):
        return render('templates/derived/template2', {'msg': 'msg1'}, request)
    

    There are obviously benefits and caveats to each approach.

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

Sidebar

Related Questions

I am attempting to implement the Visitor Design Pattern using OCaml's OO constructs and
I have a web form that I am attempting to implement dynamic drop down
I'm attempting to override and implement my own TabExpansion. In the function I want
I'm attempting to implement a repository pattern with my poco objects auto generated from
I am attempting to implement a function that sorts a randomly generated vector using
I'm attempting to implement a PreInsertEvent listener using the latest version (which was at
Question: I'm new to the repository pattern, and I'm attempting to implement a new
I'm attempting to implement a phpBB library into Kohana. I have created a vendor
I am attempting to implement a pagination bar above a table. I have a
I'm attempting to implement a MVP pattern in my latest project. Currently using the

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.