Created
February 7, 2014 19:46
-
-
Save ianjosephwilson/8870333 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There should only be a few permissions across your whole application. | |
permissions = { | |
'view': 'view', | |
} | |
class RegContextFactory(): | |
@property | |
def __acl__(self): | |
if self.base != 'x': | |
return [ | |
DENY_ALL | |
] | |
else: | |
return [ | |
(Allow, 'g:users', permissions['view']), | |
] | |
def __init__(self, request): | |
self.request = request | |
# This essentially is used to create 2 contexts, | |
# one for base == x and one for base != x. | |
self.base = self.request.matchdict.get('base') | |
class RegCustomView(): | |
def __init__(self, context, request): | |
self.context = context | |
self.request = request | |
def full_reg(self): | |
return Response('ok') | |
config.add_route('full_reg', '{base}/reg/{id}/full', factory=RegContextFactory) | |
config.add_view(view=RegCustomView, attr='full_reg', route_name='full_reg', request_method='GET', | |
permission=permissions['view']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment