You can use pyramid.security.has_permission() to check access to a
particular permission. view_execution_permitted is traversal-only.

For has_permission() you just need to be sure to pass in the context that
contains the correct ACLs for that view.

On Mon, Nov 14, 2011 at 12:18 PM, Mark Erbaugh <m...@microenh.com> wrote:

>
> On Nov 14, 2011, at 10:29 AM, Mattias wrote:
>
> Is there anyway to check if the user have the required permissions
> when I only know the route_name?
>
> def main(global_config, **settings):
> [snip]
> config.add_route('administrations', '/administrations')
>
> class Administration(object):
> def __init__(self, request):
>  self.request = request
>
> @view_config(route_name = 'administrations',
>       renderer='administration.mako',
>       permission='admin)
> def admin(self):
>  return {'name':'test'}
>
> I tried view_execution_permitted(self.request.context, self.request,
> view_name) but since I am using URL dispatch my views don't have any
> view_names so that functions always return a Allowed() instance.
>
>
>
> My understanding is that if someone without admin permission would
> automatically get a HTTP Forbidden response if they try to visit the
> administrations page. In fact, in the documentation under the SQLAlchemy +
> URL Dispatch Tutorial, the HTTP Forbidden view is remapped to the login
> screen. Thus, if someone tries to access the page withouth proper
> credentials, they get a chance to provide those credentials.
>
> Or am I missing something in your question?
>
> Mark
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>



-- 

Michael

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to