Commit 164c370d authored by Nicolas Dumazet's avatar Nicolas Dumazet

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.)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43229 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0515396
......@@ -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)
......@@ -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)
......@@ -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)
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