From 149dfbc19e6017eb45023c6ddaae116f7ce511f8 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Thu, 28 Sep 2017 15:26:24 +0200 Subject: [PATCH] moved child nodes to base resource class --- ordr2/resources/__init__.py | 6 +----- ordr2/resources/base.py | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ordr2/resources/__init__.py b/ordr2/resources/__init__.py index 8d0834b..5f19bdd 100644 --- a/ordr2/resources/__init__.py +++ b/ordr2/resources/__init__.py @@ -11,7 +11,7 @@ class Root(BaseResource): __name__ = None __parent__ = None - _nodes = { + nodes = { 'account': Account, 'admin': Admin } @@ -22,10 +22,6 @@ class Root(BaseResource): def __acl__(self): return [ (Allow, Everyone, 'view') ] - def __getitem__(self, key): - klass = self._nodes[key] - return klass(key, self) - def includeme(config): ''' diff --git a/ordr2/resources/base.py b/ordr2/resources/base.py index fb67aa2..75f488c 100644 --- a/ordr2/resources/base.py +++ b/ordr2/resources/base.py @@ -8,6 +8,7 @@ class BaseResource(object): request = None model = None + nodes = {} nav_highlight = None @@ -18,3 +19,7 @@ class BaseResource(object): def __acl__(self): return [ DENY_ALL ] + + def __getitem__(self, key): + klass = self.nodes[key] + return klass(key, self)