Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use __acl__ in version 3 #467

Open
circlingthesun opened this issue Dec 9, 2017 · 2 comments
Open

Document how to use __acl__ in version 3 #467

circlingthesun opened this issue Dec 9, 2017 · 2 comments

Comments

@circlingthesun
Copy link
Contributor

Is there an example of how to use an acl with a Service in version 3? The docs only mention Resources.

@leplatrem
Copy link
Contributor

If I'm not wrong you can simply pass a factory argument to your service

@leplatrem leplatrem changed the title __acl__ in version 3 Document how to use __acl__ in version 3 Apr 3, 2018
@circlingthesun
Copy link
Contributor Author

Thanks for the tip. I finally got around to upgrading. It would probably helpful to have in the docs. I did the following:

class BusinessACL(object):
    def __init__(self, request):
        self.request = request

    def __acl__(self):
        business_id = self.request.matchdict['id']
        return [
            (Allow, 'group:root', ALL_PERMISSIONS),
            (Allow, 'group:admin-%s' % business_id, 'write'),
            (Allow, Everyone, 'read'),
        ]

calendar_export = Service(
    name='calendar',
    path='/api/business/{id:\d+}/calendar.ics',
    description="ICS export for business",
    factory=BusinessACL
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants