CPI Ordering System (the old version)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

50 lines
1.3 KiB

''' Resources (sub) package, used to connect URLs to views '''
from pyramid.security import Allow, Everyone, DENY_ALL
from .account import RegistrationResource
class RootResource:
''' The root resource for the application
:param pyramid.request.Request request: the current request object
'''
nav_active = 'welcome'
def __init__(self, request):
''' Create the root resource
:param pyramid.request.Request request: the current request object
'''
self.__name__ = None
self.__parent__ = None
self.request = request
def __acl__(self):
''' access controll list for the resource '''
return [(Allow, Everyone, 'view'), DENY_ALL]
def __getitem__(self, key):
''' retruns a child resource
:param str key: name of the child resource
:returns: child resource
:raises: KeyError if child resource is not found
'''
map = {
'register': RegistrationResource
}
child_class = map[key]
return child_class(request=self.request, name=key, parent=self)
def includeme(config):
'''
Initialize the resources for traversal in a Pyramid app.
Activate this setup using ``config.include('ordr2.resources')``.
'''
config.set_root_factory(RootResource)