diff --git a/ordr/__init__.py b/ordr/__init__.py index 8f2c40c..c4b73e9 100644 --- a/ordr/__init__.py +++ b/ordr/__init__.py @@ -3,10 +3,6 @@ from pyramid.config import Configurator __version__ = '0.0.1' -def root_factory(request): - ''' dummy root factory ''' - return dict() - def main(global_config, **settings): """ This function returns a Pyramid WSGI application. @@ -14,7 +10,7 @@ def main(global_config, **settings): config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') + config.include('.resources') config.add_static_view('static', 'static', cache_max_age=3600) - config.set_root_factory(root_factory) config.scan() return config.make_wsgi_app() diff --git a/ordr/resources/__init__.py b/ordr/resources/__init__.py new file mode 100644 index 0000000..4c38897 --- /dev/null +++ b/ordr/resources/__init__.py @@ -0,0 +1,33 @@ +''' Resources (sub) package, used to connect URLs to views ''' + +from pyramid.security import Allow, Everyone, DENY_ALL + + +class RootResource: + ''' The root resource for the application + + :param pyramid.request.Request request: the current request object + ''' + + 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 includeme(config): + ''' + Initialize the resources for traversal in a Pyramid app. + + Activate this setup using ``config.include('ordr2.resources')``. + + ''' + config.set_root_factory(RootResource)