Commit de62f3e8 authored by Jean-Paul Smets's avatar Jean-Paul Smets

conflict solved - getRelatedValue now checks brain before doing anything


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@440 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b66ab393
...@@ -873,6 +873,21 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -873,6 +873,21 @@ class CategoryTool( UniqueObject, Folder, Base ):
return 1 return 1
return 0 return 0
security.declareProtected( Permissions.AccessContentsInformation, 'isAcquiredMemberOf' )
def isAcquiredMemberOf(self, context, category):
"""
Tests if an object if member of a given category
Category is a string here. It could be more than a string (ex. an object)
XXX Should include acquisition ?
"""
if getattr(aq_base(context), 'isCategory', 0):
return context.isAcquiredMemberOf(category)
for c in self._getAcquiredCategoryList(context):
if c.find(category) >= 0:
return 1
return 0
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryList' )
def getCategoryList(self, context): def getCategoryList(self, context):
self._cleanupCategories(context) self._cleanupCategories(context)
...@@ -936,6 +951,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -936,6 +951,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
""" """
for brain in self.search_related(category_uid = context.getUid()): for brain in self.search_related(category_uid = context.getUid()):
o = brain.getObject() o = brain.getObject()
if o is not None:
category_list = [] category_list = []
for category in self.getCategoryList(o): for category in self.getCategoryList(o):
new_category = re.sub('(?P<start>.*)/%s/(?P<stop>.*)' % new_category = re.sub('(?P<start>.*)/%s/(?P<stop>.*)' %
...@@ -945,6 +961,8 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -945,6 +961,8 @@ class CategoryTool( UniqueObject, Folder, Base ):
category_list += [new_category] category_list += [new_category]
#LOG('updateRelatedContent of %s' % o.getRelativeUrl(), 0, str(category_list)) #LOG('updateRelatedContent of %s' % o.getRelativeUrl(), 0, str(category_list))
self._setCategoryList(o, category_list) self._setCategoryList(o, category_list)
else:
LOG('WARNING updateRelatedContent',0,'%s does not exist' % brain.path)
aq_context = aq_base(context) aq_context = aq_base(context)
# Update related recursively if required # Update related recursively if required
if hasattr(aq_context, 'listFolderContents'): if hasattr(aq_context, 'listFolderContents'):
......
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