Commit 4c3e35e5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

* Fix typos

* Add missing setters
* Fix categories list which contained missing categories



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43344 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57f82b20
...@@ -118,6 +118,10 @@ class CategoryProperty(XMLObject): ...@@ -118,6 +118,10 @@ class CategoryProperty(XMLObject):
} }
setter_definition_dict = { setter_definition_dict = {
# public 'reindexers' # public 'reindexers'
'set%s': Alias.Reindex,
'set%sList': Alias.Reindex,
'setDefault%s': Alias.Reindex,
'set%sSet': Alias.Reindex,
'set%sValue': Alias.Reindex, 'set%sValue': Alias.Reindex,
'set%sValueList': Alias.Reindex, 'set%sValueList': Alias.Reindex,
'set%sValueSet': Alias.Reindex, 'set%sValueSet': Alias.Reindex,
...@@ -127,6 +131,14 @@ class CategoryProperty(XMLObject): ...@@ -127,6 +131,14 @@ class CategoryProperty(XMLObject):
'set%sUidSet': Alias.Reindex, 'set%sUidSet': Alias.Reindex,
'setDefault%sUid': Alias.Reindex, 'setDefault%sUid': Alias.Reindex,
# setters # setters
'_set%s': Category.Setter,
'_categorySet%s': Category.Setter,
'_set%sList': Category.ListSetter,
'_categorySet%sList': Category.ListSetter,
'_setDefault%s': Category.DefaultSetter,
'_categorySetDefault%s': Category.DefaultSetter,
'_set%sSet': Category.SetSetter,
'_categorySet%sSet': Category.SetSetter,
'_set%sValue': Value.Setter, '_set%sValue': Value.Setter,
'_categorySet%sValue': Value.Setter, '_categorySet%sValue': Value.Setter,
'_set%sValueList': Value.ListSetter, '_set%sValueList': Value.ListSetter,
...@@ -172,7 +184,7 @@ class CategoryProperty(XMLObject): ...@@ -172,7 +184,7 @@ class CategoryProperty(XMLObject):
StandardProperty.applyPropertyOnAccessorHolder( StandardProperty.applyPropertyOnAccessorHolder(
accessor_holder=accessor_holder, accessor_holder=accessor_holder,
portal=category_tool, portal=category_tool.getPortalObject(),
reference='%s_free_text' % category_id, reference='%s_free_text' % category_id,
elementary_type='text', elementary_type='text',
multivalued=False, multivalued=False,
...@@ -188,45 +200,45 @@ class CategoryProperty(XMLObject): ...@@ -188,45 +200,45 @@ class CategoryProperty(XMLObject):
Permissions.ModifyPortalContent) Permissions.ModifyPortalContent)
# Actually create accessors # Actually create accessors
uppercase_reference = UpperCase(category_id) uppercase_category_id = UpperCase(category_id)
# three special cases # three special cases
accessor = Category.Tester('has' + uppercase_reference, id) accessor = Category.Tester('has' + uppercase_category_id, category_id)
accessor_holder.registerAccessor(accessor, read_permission) accessor_holder.registerAccessor(accessor, read_permission)
accessor_name = uppercase_reference[0].lower() + uppercase_reference[1:] accessor_name = uppercase_category_id[0].lower() + uppercase_category_id[1:]
accessor = Value.ListGetter(accessor_name + 'Values', id) accessor = Value.ListGetter(accessor_name + 'Values', category_id)
accessor_holder.registerAccessor(accessor, read_permission) accessor_holder.registerAccessor(accessor, read_permission)
accessor = Value.IdListGetter(accessor_name + 'Ids', id) accessor = Value.IdListGetter(accessor_name + 'Ids', category_id)
accessor_holder.registerAccessor(accessor, read_permission) accessor_holder.registerAccessor(accessor, read_permission)
# then getters # then getters
for id_format, accessor_class in cls.getter_definition_dict.iteritems(): for id_format, accessor_class in cls.getter_definition_dict.iteritems():
accessor_name = id_format % uppercase_reference accessor_name = id_format % uppercase_category_id
public_accessor = accessor_class(accessor_name, id) public_accessor = accessor_class(accessor_name, category_id)
accessor_holder.registerAccessor(public_accessor, read_permission) accessor_holder.registerAccessor(public_accessor, read_permission)
# create the private getter on the fly instead of having a definition dict # create the private getter on the fly instead of having a definition dict
# that's twice the size for the same info # that's twice the size for the same info
accessor_name = '_category' + accessor_name[0].upper() + accessor_name[1:] accessor_name = '_category' + accessor_name[0].upper() + accessor_name[1:]
private_accessor = accessor_class(accessor_name, id) private_accessor = accessor_class(accessor_name, category_id)
accessor_holder.registerAccessor(private_accessor, read_permission) accessor_holder.registerAccessor(private_accessor, read_permission)
# and setters # and setters
for id_format, accessor_class in cls.setter_definition_dict.iteritems(): for id_format, accessor_class in cls.setter_definition_dict.iteritems():
accessor_name = id_format % uppercase_reference accessor_name = id_format % uppercase_category_id
accessor = accessor_class(accessor_name, id) accessor = accessor_class(accessor_name, category_id)
accessor_holder.registerAccessor(accessor, write_permission) accessor_holder.registerAccessor(accessor, write_permission)
accessor_holder._categories.append(category_id)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'applyOnAccessorHolder') 'applyOnAccessorHolder')
def applyOnAccessorHolder(self, accessor_holder, expression_context, portal): def applyOnAccessorHolder(self, accessor_holder, expression_context, portal):
reference = self.getReference() reference = self.getReference()
if reference is not None: if reference is not None:
accessor_holder._categories.append(reference)
category_tool = getattr(portal, 'portal_categories', None)
self.applyPropertyOnAccessorHolder(accessor_holder, self.applyPropertyOnAccessorHolder(accessor_holder,
reference, reference,
category_tool) getattr(portal, 'portal_categories', None))
...@@ -86,4 +86,3 @@ class DynamicCategoryProperty(CategoryProperty): ...@@ -86,4 +86,3 @@ class DynamicCategoryProperty(CategoryProperty):
self.applyPropertyOnAccessorHolder(accessor_holder, self.applyPropertyOnAccessorHolder(accessor_holder,
category_id, category_id,
category_tool) category_tool)
accessor_holder._categories.append(category_id)
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