[Erp5-report] r43229 nicolas.dumazet - in /erp5/trunk/products/ERP5Type: Core/ mixin/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Feb 9 11:10:21 CET 2011


Author: nicolas.dumazet
Date: Wed Feb  9 11:10:21 2011
New Revision: 43229

URL: http://svn.erp5.org?rev=43229&view=rev
Log:
Beginning of new API to apply properties to accessor holders.

The idea is to call specialized applyOnAccessorHolder methods on each property
to generate accessors instead of relying on the bloated Utils.py way

(This code is unused as of now.)

Modified:
    erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
    erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py
    erp5/trunk/products/ERP5Type/mixin/constraint.py

Modified: erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryProperty.py?rev=43229&r1=43228&r2=43229&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] Wed Feb  9 11:10:21 2011
@@ -65,3 +65,10 @@ class CategoryProperty(XMLObject):
     """
     return context.newContent(portal_type=cls.portal_type,
                               reference=category_name)
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'applyOnAccessorHolder')
+  def applyOnAccessorHolder(self, accessor_holder, expression_context):
+    reference = self.getReference()
+    if reference is not None:
+      accessor_holder._categories.append(reference)

Modified: erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py?rev=43229&r1=43228&r2=43229&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/DynamicCategoryProperty.py [utf8] Wed Feb  9 11:10:21 2011
@@ -70,3 +70,13 @@ class DynamicCategoryProperty(XMLObject)
     """
     return context.newContent(portal_type=cls.portal_type,
                               category_expression=category_expression.text)
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'applyOnAccessorHolder')
+  def applyOnAccessorHolder(self, accessor_holder, expression_context):
+    expression_string = self.getCategoryExpression()
+    if expression_string is not None:
+      expression = Expression(expression_string)
+      for category_id in expression(expression_context):
+        if category_id is not None:
+          accessor_holder._categories.append(category_id)

Modified: erp5/trunk/products/ERP5Type/mixin/constraint.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/mixin/constraint.py?rev=43229&r1=43228&r2=43229&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/mixin/constraint.py [utf8] Wed Feb  9 11:10:21 2011
@@ -239,3 +239,8 @@ class ConstraintMixin(Predicate):
       filesystem_definition_dict[message_id] = self._getMessage(message_id)
 
     return filesystem_definition_dict
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'applyOnAccessorHolder')
+  def applyOnAccessorHolder(self, accessor_holder, expression_context):
+    accessor_holder.constraints.append(self)



More information about the Erp5-report mailing list