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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:54:09+00:00 2026-06-07T08:54:09+00:00

I read the cookbook article on making user objects avail to all requests but

  • 0

I read the cookbook article on making user objects avail to all requests but I may not understand it fully because I can’t see if it is related to my problem.

I render quite a few templates on a site I’m working on and there’s different user info each templates needs. For example, like this page on SO my every page needs to display my username, points, number of notifications, number of badges, etc. I have all this information but I find myself having to add it to each request dictionary I send to the template like so:

return dict(page=page, name=name, save_url=save_url,
                logged_in=authenticated_userid(request), title='add new', url='/new', points=points, num_badges=badges)

Is there a way to combine all this once so I can just send one entry to each view? I’m sure its not good to run the same query every time but its also annoying to have to type it for every view. Any suggestions?

  • 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-07T08:54:10+00:00Added an answer on June 7, 2026 at 8:54 am

    The simplest method would be to generate your ‘common’ information in one method, returning a dict, then updating your local view dict with that information

    local = dict(page=page, name=name, save_url=save_url, title='add new',
         url='/new', points=points, num_badges=badges)
    local.update(retrieve_common_information(request))
    return local
    

    Another method is to use something like the pyramid_viewgroup (documentation now located at a new location), where you delegate the rendering of common ‘snippets’ of your pages to separate views.

    One such view could take care of the common user information you want to render, and be reused everywhere.

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

Sidebar

Related Questions

I read an article about a regular expression to detect base64 but when I
Read this question carefully because I am not asking how to get rid of
Read this question about how to compare custom objects in C++. I did not
I already read the respective article in Celery docs ( Cookbook :: Creating Tasks
I read Python Cookbook and see what in a recipe Finding the Intersection of
I already read this trick in the cookbook: http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable Now I would like to
I just finished reading the HTML5 Developer's Cookbook and have a question. I've read
Read on before you say this is a duplicate, it's not. (as far as
Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php .
I read http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html but have some issues. For pre-honeycomb I want a custom title,

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.