[Erp5-report] r43246 nicolas.dumazet - /erp5/trunk/products/ERP5Type/dynamic/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 10 04:57:31 CET 2011


Author: nicolas.dumazet
Date: Thu Feb 10 04:57:30 2011
New Revision: 43246

URL: http://svn.erp5.org?rev=43246&view=rev
Log:
helper to register Accessors directly on the Accessor Holder

Modified:
    erp5/trunk/products/ERP5Type/dynamic/accessor_holder.py

Modified: erp5/trunk/products/ERP5Type/dynamic/accessor_holder.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dynamic/accessor_holder.py?rev=43246&r1=43245&r2=43246&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/dynamic/accessor_holder.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/dynamic/accessor_holder.py [utf8] Thu Feb 10 04:57:30 2011
@@ -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 In
 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,



More information about the Erp5-report mailing list