pyramid - Use permissions to create differents views of the same route -
i want expose rest service , use permission context call different methods (simple user vs admin user).
what did (simple example):
config.add_route('rest', '/url') .... @view_config(route_name="rest", renderer="json", request_method='get', permission='user') def firstmethod(request): ... @view_config(route_name="rest", renderer="json", request_method='get', permission='admin') def secondmethod(request): ... but have following error when start pyramid :
"configurationconflicterror: conflicting configuration actions"
for firstmethod , secondmethod
any ideas solve problem ? (i know can use principals need use permission , not principal...)
your permissions right labeled principals, not permissions, might want think how you're using permissions. principals more characteristics (groups), whereas permissions verbs (what can user do).
as martijn said, way acl model works it's difficult in general sense reason whether 1 permission mutually exclusive arbitrary permissions. example, 'admin' users not 'user' users?? guess that's you.
pyramid provides tiny way cheat via effective_principals predicate, if these principals want differentiate. again have make sure mutually exclusive or won't know view invoked.
@view_config(route_name='foo', effective_principals=['admin']) if admins have 'user' principal, you'd leave 'user' out of next view_config, such:
@view_config(route_name='foo') now it's unambiguous.
the way make unambiguous in other cases own view predicates.
@view_config(route_name='foo', is_admin=true) @view_config(route_name='foo', effective_principals=[authenticated]) config.add_view_predicate('is_admin', adminpredicate)
Comments
Post a Comment