Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

If view_permission **kw arg is passed to add_handler, pass it through to add_view calls #1

Closed
wylee opened this Issue April 26, 2011 · 3 comments

2 participants

Wyatt mattlevesque
Wyatt
wylee commented April 26, 2011

Currently, if you try to use the view_permission argument in an
add_handler call, it results in a ConfigurationError:

view_permission argument not permitted without view argument

Since handlers are all about convenience, I think it makes sense to
be able to set the permissions for all the views in a handler this
way.

A possible solution would be to pop view_permission from **kw before
calling add_route and then using that value as the default permission
when add_view is called. If a different permission is specified via
the @action decorator, it would override the default.

I can whip up a patch if there's any interest in adding this
feature.

PS Sorry about the resubmission. I deleted my original GH account over the weekend (for uninteresting reasons), and this issue was deleted too. I thought I should add it back, since it was still open.

mattlevesque

Ok but for now how can we put permissions on our handlers?

I love that handlers can group related actions together but I find that the lack of documentation is making the use of it quite tedious... I really didn't like to see the new layout for Pyramid being with views, looks to me like a step backward from Pylons.

mattlevesque

Got it to work with the action decorator saw an example in your tests cases.

It would be nice to set the permission for all the actions at once like wylee suggested.

Wyatt wylee closed this August 07, 2011
Wyatt wylee reopened this August 07, 2011
Wyatt

@mattlevesque, I submitted a patch to implement the suggestion above, and it's included in pyramid_handlers 0.2, so now you can do something like this to set a default permission for all actions in a handler:

config.add_handler('hello', '/hello/{action}', handler='my.handlers.Hello', view_permission='perm')
Wyatt wylee closed this August 07, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.