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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:59:33+00:00 2026-05-25T12:59:33+00:00

In pyramid, I have created a ‘helpers’ functionality similar to that in pylons. one

  • 0

In pyramid, I have created a ‘helpers’ functionality similar to that in pylons.

one particular function in my helpers.py file is like this:

from pyramid.renderers import render_to_response

def createBlog():
    ## lots of code here ##
    return render_to_response('blog.mako', {'xyz':xyz})

And then in my other applications I can import helpers and do something like the following in my templates:

${h.createBlog()}

which creates a blog on my page. But I am just wondering is this a good way of using helpers to create “module” style plugins that I can easily use anywhere in my projects. Or are there any flaws to this technique which I haven’t really thought of yet?

Thanks!

  • 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-25T12:59:33+00:00Added an answer on May 25, 2026 at 12:59 pm

    It really depends on how much stuff you want to expose globally. Obviously anything you put into h is available throughout the application, whereas you could return the createBlog function just in the views you want it to be in. One little-known tidbit is that if you use class-based views, the actual class instance is available in the view as the view global variable. For example:

    class Foo(object):
        def __init__(self, request):
            self.request = request
    
        def createBlog(self):
            return render('blog.mako'. {})
    
        @view_config(...)
        def myview(self):
            return {}
    

    Now in your template you can call render your blog using ${view.createBlog()}.

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

Sidebar

Related Questions

I have a Pyramid app that uses Chameleon for its templates. I would like
I have a Pyramid app that I've been developing and viewing locally through http://localhost:6543
I am building a Form object using pyramid_simpleform. I would like to have one
I have a riddle for you. I need a function that displays the number
I am working on a pyramid web application that uses SQLAlchemy. I have a
Ok here is the problem in brief. I do have a pyramid setup that
I have a custom 404 view defined in my Pyramid app: @view_config(context=HTTPNotFound, renderer='404.pt') def
How to write a query suitable for generating an age pyramid like this: I
I am creating custom images that I later convert to an image pyramid for
I have a Pyramid app and apache with mod_wsgi and I'm trying to make

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.