Hi, I'd like to do the simplest possible thing in Pyramid / URL Dispatch, 
yet it seems almost impossibly hard to do it.

So it's the super common case of having a menu, and I'd only like to insert 
menu items which are available for the current user.

I'm looking for a function to fit in this usage:

{% macro nav_item(request, route_name, text) -%}
  {% if request.view_execution_permitted(route_name) %}
    <li>
      <a href="{{ request.route_url(route_name) }}">{{ text }}</a>
    </li>
  {% endif %}
{%- endmacro %}


My problems are the following:

1. view_execution_permitted doesn't work like this, unlike other security 
functions, for example request.has_permission(). Why?

2. Going the hard way and making a custom wrapper around 
view_execution_permitted, 
and adding it to request via add_request_method, I'm still stuck in how to 
use view_execution_permitted, for the following reason:

2.1. It needs a context. What is a context? I never had to use any context 
in URL Dispatch with SessionAuthenticationPolicy, and it really isn't 
explained on the website. I tried Googling view_execution_permitted and 
grepping for code in Github, but I couldn't find anything, except a Github 
issue ticket saying: "view_execution_permitted does not work with URL 
dispatch", which didn't help me.
https://github.com/Pylons/pyramid/issues/673

2.2. It needs a name. Is this route_name? I hope so? 

Maybe I don't even need view_execution_permitted. I just want a simple 
request.is_allowed_route(route_name). How can I do it?

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/a5285237-b1a5-44e5-bd5e-3fd0e4b11c44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to