Skip to content

Instantly share code, notes, and snippets.

@ianjosephwilson
Created February 7, 2014 19:46
Show Gist options
  • Save ianjosephwilson/8870333 to your computer and use it in GitHub Desktop.
Save ianjosephwilson/8870333 to your computer and use it in GitHub Desktop.
# 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