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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.