Commit dc825218 authored by Nicolas Dumazet's avatar Nicolas Dumazet

helper to register Accessors directly on the Accessor Holder


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43246 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 61c620af
......@@ -35,6 +35,7 @@ moving specialized code here.
"""
import sys
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import PropertyHolder, Base
from Products.ERP5Type.Utils import createRelatedAccessors, createExpressionContext
from Products.ERP5Type.Utils import setDefaultClassProperties, setDefaultProperties
......@@ -43,6 +44,18 @@ from Products.ERP5Type.Globals import InitializeClass
from zLOG import LOG, ERROR, INFO
class AccessorHolderType(type):
_skip_permission_set = set(Permissions.AccessContentsInformation,
Permissions.ModifyPortalContent)
def registerAccessor(cls,
accessor,
permission):
accessor_name = accessor.__name__
setattr(cls, accessor_name, accessor)
# private accessors do not need declarative security
if accessor_name[0] != '_' and \
permission not in AccessorHolderType._skip_permission_set:
cls.security.declareProtected(permission, accessor_name)
@classmethod
def fromPropertyHolder(meta_type,
property_holder,
......
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