Browse Source

added Account resource

php2python
Holger Frey 7 years ago
parent
commit
3bfe633260
  1. 13
      ordr2/resources/__init__.py
  2. 15
      ordr2/resources/account.py
  3. 19
      ordr2/resources/base.py

13
ordr2/resources/__init__.py

@ -1,12 +1,18 @@ @@ -1,12 +1,18 @@
from pyramid.security import Allow, Everyone
class Root(object):
from .account import Account
from .base import BaseResource
class Root(BaseResource):
''' Root resource '''
__name__ = None
__parent__ = None
nav_highlight = None
_nodes = [
'account': Account
]
def __init__(self, request):
self._request = request
@ -14,6 +20,9 @@ class Root(object): @@ -14,6 +20,9 @@ class Root(object):
def __acl__(self):
return [ (Allow, Everyone, 'view') ]
def __getitem__(self, key):
klass = self._nodes[key]
return klass(key, self)
def includeme(config):

15
ordr2/resources/account.py

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
from pyramid.security import Allow, Authenticated, Deny, Everyone
from .base import BaseResource
class Account(BaseResource):
def __acl__(self):
return [
(Allow, Everyone, 'login'),
(Allow, Everyone, 'logout'),
(Deny, Authenticated, 'register'),
(Allow, Everyone, 'register'),
(Allow, Authenticated, 'settings'),
]

19
ordr2/resources/base.py

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
from pyramid.security import DENY_ALL
class BaseResource(object):
__parent__ = None
__name__ = None
_request = None
nav_highlight = None
def __init__(self, name, parent):
self.__name__ = name
self.__parent__ = parent
self._request = parent._request
def __acl__(self):
return [ DENY_ALL ]