Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the the 'view' global renderer variable in the panel #29

Open
geohuz opened this issue Jun 23, 2014 · 4 comments
Open

How to get the the 'view' global renderer variable in the panel #29

geohuz opened this issue Jun 23, 2014 · 4 comments

Comments

@geohuz
Copy link

geohuz commented Jun 23, 2014

I found in the panel template there is no 'view' renderer global variable there, I was trying to get it through the introspectable but failed. Is there an easy way to get it?

@chrisrossi
Copy link
Member

Hi George,

I assume this is because there is some helper method on a class based view
that you want to call in the template? 'view' isn't available, but 'panel'
is. You could always use a class based panel and have your helper function
on the panel class. You could probably even mix view_config and
panel_config on different methods of the same class, so you could have
panels and views in the same class which would share the same helper
methods.

Panels can also accept arbitrary keyword arguments, so you could always
pass the view from the main template to the panel.

Chris

On Mon, Jun 23, 2014 at 7:33 AM, geohuz [email protected] wrote:

I found in the panel template there is no 'view' renderer global variable
there, I was trying to figure out how to get it through the introspectable
but failed. Is there a easy to get it?


Reply to this email directly or view it on GitHub
#29.

@geohuz
Copy link
Author

geohuz commented Jun 24, 2014

Thanks Chris, now I have another issue to get the current panel callable name, basically I want to display the function or callable name in the page, when I use panel renderer variable, it displays something like bound method LayoutManager.render_panel of <pyramid_layout.layout.LayoutManager object at 0x10950d3d0

@chrisrossi
Copy link
Member

Hi George, I goofed. 'panel' is the render_panel callable used to render panels inside of a template. It is not the panel currently being rendered. I would suggest looking for a different way to get that information into your page. Sorry for the confusion.

@geohuz
Copy link
Author

geohuz commented Jul 3, 2014

I changed the source code in config.py, the function add_renderer_globals to this:

def add_renderer_globals(event):
    if 'panel' in event:
        event['panel_callable'] = event['panel']
    request = event['request']
    ...

I'm not sure if this is the best way to fix my problem, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants