Commit aa3b86ae authored by Jérome Perrin's avatar Jérome Perrin

consistant security declarations

fix documentation
cleanups



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12546 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9e302cd2
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
$Id$ $Id$
""" """
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Acquisition import aq_inner, aq_parent from Acquisition import aq_inner, aq_parent
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
...@@ -24,18 +24,16 @@ from Products.CMFCore.utils import getToolByName ...@@ -24,18 +24,16 @@ from Products.CMFCore.utils import getToolByName
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Permissions import View from Permissions import View
from Permissions import ManagePortal
from types import StringType ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = \
'ERP5Type_getSecurityCategoryFromAssignment'
ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = 'ERP5Type_getSecurityCategoryFromAssignment'
class RoleInformation( SimpleItem ): class RoleInformation( SimpleItem ):
""" Represent a single selectable role. """ Represent a role definition.
Roles generate links to views of content, or to specific methods Roles definitions defines local roles on ERP5Type documents. They are
of the site. They can be filtered via their conditions. applied by the updateLocalRolesOnSecurityGroups method.
""" """
_isRoleInformation = 1 _isRoleInformation = 1
__allow_access_to_unprotected_subobjects__ = 1 __allow_access_to_unprotected_subobjects__ = 1
...@@ -90,7 +88,7 @@ class RoleInformation( SimpleItem ): ...@@ -90,7 +88,7 @@ class RoleInformation( SimpleItem ):
else: else:
return 1 return 1
security.declarePublic( 'getRole' ) security.declareProtected( View, 'getRole' )
def getRole( self, ec ): def getRole( self, ec ):
""" Compute the role using context, 'ec'; return a mapping of """ Compute the role using context, 'ec'; return a mapping of
...@@ -105,14 +103,14 @@ class RoleInformation( SimpleItem ): ...@@ -105,14 +103,14 @@ class RoleInformation( SimpleItem ):
info['base_category_script'] = self.getBaseCategoryScript() info['base_category_script'] = self.getBaseCategoryScript()
return info return info
security.declarePublic( 'getCondition' ) security.declareProtected( View, 'getCondition' )
def getCondition(self): def getCondition(self):
""" Return the text of the TALES expression for our condition. """ Return the text of the TALES expression for our condition.
""" """
return getattr( self, 'condition', None ) and self.condition.text or '' return getattr( self, 'condition', None ) and self.condition.text or ''
security.declarePublic( 'getCategory' ) security.declareProtected( View, 'getCategory' )
def getCategory( self ): def getCategory( self ):
""" Return the category """ Return the category
...@@ -120,9 +118,10 @@ class RoleInformation( SimpleItem ): ...@@ -120,9 +118,10 @@ class RoleInformation( SimpleItem ):
Strip any return or ending space Strip any return or ending space
""" """
return tuple(map(lambda x: x.strip(), filter(lambda x: x, self.category))) or () return tuple(map(lambda x: x.strip(),
filter(lambda x: x, self.category))) or ()
security.declarePublic( 'getBaseCategory' ) security.declareProtected( View, 'getBaseCategory' )
def getBaseCategory( self ): def getBaseCategory( self ):
""" Return the base_category """ Return the base_category
...@@ -130,7 +129,7 @@ class RoleInformation( SimpleItem ): ...@@ -130,7 +129,7 @@ class RoleInformation( SimpleItem ):
""" """
return tuple(getattr(self, 'base_category', ())) return tuple(getattr(self, 'base_category', ()))
security.declarePublic( 'getBaseCategoryScript' ) security.declareProtected( View, 'getBaseCategoryScript' )
def getBaseCategoryScript( self ): def getBaseCategoryScript( self ):
""" Return the base_category_script id """ Return the base_category_script id
...@@ -140,7 +139,7 @@ class RoleInformation( SimpleItem ): ...@@ -140,7 +139,7 @@ class RoleInformation( SimpleItem ):
return base_category_script return base_category_script
return ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT return ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT
security.declarePrivate( 'base_category' ) security.declarePrivate( 'clone' )
def clone( self ): def clone( self ):
""" Return a newly-created RI just like us. """ Return a newly-created RI just like us.
...@@ -152,7 +151,8 @@ class RoleInformation( SimpleItem ): ...@@ -152,7 +151,8 @@ class RoleInformation( SimpleItem ):
, condition=self.getCondition() , condition=self.getCondition()
, priority =self.priority , priority =self.priority
, base_category=self.base_category , base_category=self.base_category
, base_category_script=getattr(self, 'base_category_script', '') , base_category_script=getattr(self,
'base_category_script', '')
) )
InitializeClass( RoleInformation ) InitializeClass( RoleInformation )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment