Browse Source

moved child nodes to base resource class

php2python
Holger Frey 7 years ago
parent
commit
149dfbc19e
  1. 6
      ordr2/resources/__init__.py
  2. 5
      ordr2/resources/base.py

6
ordr2/resources/__init__.py

@ -11,7 +11,7 @@ class Root(BaseResource):
__name__ = None __name__ = None
__parent__ = None __parent__ = None
_nodes = { nodes = {
'account': Account, 'account': Account,
'admin': Admin 'admin': Admin
} }
@ -22,10 +22,6 @@ class Root(BaseResource):
def __acl__(self): def __acl__(self):
return [ (Allow, Everyone, 'view') ] return [ (Allow, Everyone, 'view') ]
def __getitem__(self, key):
klass = self._nodes[key]
return klass(key, self)
def includeme(config): def includeme(config):
''' '''

5
ordr2/resources/base.py

@ -8,6 +8,7 @@ class BaseResource(object):
request = None request = None
model = None model = None
nodes = {}
nav_highlight = None nav_highlight = None
@ -18,3 +19,7 @@ class BaseResource(object):
def __acl__(self): def __acl__(self):
return [ DENY_ALL ] return [ DENY_ALL ]
def __getitem__(self, key):
klass = self.nodes[key]
return klass(key, self)