Commit 7939c0d8 authored by Aurel's avatar Aurel

raise a more user friendly message, remove trailling spaces

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12671 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 88b120e7
...@@ -210,7 +210,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -210,7 +210,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
return cache[key] return cache[key]
except KeyError: except KeyError:
pass pass
try: try:
relative_url = str(relative_url) relative_url = str(relative_url)
if base_category is not None: if base_category is not None:
...@@ -219,12 +219,12 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -219,12 +219,12 @@ class CategoryTool( UniqueObject, Folder, Base ):
value = node value = node
except (TypeError, KeyError, NotFound): except (TypeError, KeyError, NotFound):
value = None value = None
if cache is not None: if cache is not None:
cache[key] = value cache[key] = value
return value return value
# security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryValue') # security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryValue')
# def getCategoryValue(self, relative_url, base_category = None): # def getCategoryValue(self, relative_url, base_category = None):
# """ # """
...@@ -608,16 +608,16 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -608,16 +608,16 @@ class CategoryTool( UniqueObject, Folder, Base ):
portal_type = kw.get('portal_type', ()) portal_type = kw.get('portal_type', ())
if isinstance(portal_type, str): if isinstance(portal_type, str):
portal_type = (portal_type,) portal_type = (portal_type,)
if spec is (): if spec is ():
spec = portal_type spec = portal_type
#LOG("set Category",0,str(category_list))
default_dict = {} default_dict = {}
self._cleanupCategories(context) self._cleanupCategories(context)
if isinstance(category_list, str): if isinstance(category_list, str):
category_list = (category_list,) category_list = (category_list,)
elif category_list is None: elif category_list is None:
category_list = () category_list = ()
elif not isinstance(category_list, list):
raise TypeError, 'Category must be a string.'
if isinstance(base_category_list, str): if isinstance(base_category_list, str):
base_category_list = [base_category_list] base_category_list = [base_category_list]
new_category_list = [] new_category_list = []
...@@ -783,23 +783,23 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -783,23 +783,23 @@ class CategoryTool( UniqueObject, Folder, Base ):
spec=(), filter=None, acquired_object_dict = None, **kw ): spec=(), filter=None, acquired_object_dict = None, **kw ):
cache = getReadOnlyTransactionCache(self) cache = getReadOnlyTransactionCache(self)
if cache is not None: if cache is not None:
key = ('getSingleCategoryAcquiredMembershipList', context._p_oid, base_category, base, spec, key = ('getSingleCategoryAcquiredMembershipList', context._p_oid, base_category, base, spec,
filter, str(kw)) filter, str(kw))
try: try:
return cache[key] return cache[key]
except KeyError: except KeyError:
pass pass
result = self._getSingleCategoryAcquiredMembershipList(context, base_category, base=base, result = self._getSingleCategoryAcquiredMembershipList(context, base_category, base=base,
spec=spec, filter=filter, spec=spec, filter=filter,
acquired_object_dict = acquired_object_dict, acquired_object_dict = acquired_object_dict,
**kw) **kw)
if cache is not None: if cache is not None:
cache[key] = result cache[key] = result
return result return result
def _getSingleCategoryAcquiredMembershipList(self, context, base_category, def _getSingleCategoryAcquiredMembershipList(self, context, base_category,
base = 0, spec = (), filter = None, base = 0, spec = (), filter = None,
acquired_portal_type = (), acquired_portal_type = (),
...@@ -878,7 +878,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -878,7 +878,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
result = self.getSingleCategoryMembershipList( context, base_category, base=base, result = self.getSingleCategoryMembershipList( context, base_category, base=base,
spec=spec, filter=filter, **kw ) # Not acquired because this is the first try spec=spec, filter=filter, **kw ) # Not acquired because this is the first try
# to get a local defined category # to get a local defined category
base_category_value = self.getCategoryValue(base_category) base_category_value = self.getCategoryValue(base_category)
#LOG("result", 0, str(result)) #LOG("result", 0, str(result))
if base_category_value is not None: if base_category_value is not None:
...@@ -1027,7 +1027,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1027,7 +1027,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
# WE MUST IMPLEMENT HERE THE REST OF THE SEMANTICS # WE MUST IMPLEMENT HERE THE REST OF THE SEMANTICS
#LOG("Get Acquired Category Result ",0,str(result)) #LOG("Get Acquired Category Result ",0,str(result))
return result return result
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getAcquiredCategoryMembershipList' ) 'getAcquiredCategoryMembershipList' )
def getAcquiredCategoryMembershipList(self, context, base_category = None, base=1, def getAcquiredCategoryMembershipList(self, context, base_category = None, base=1,
...@@ -1057,12 +1057,12 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1057,12 +1057,12 @@ class CategoryTool( UniqueObject, Folder, Base ):
""" """
Tests if an object if member of a given 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) Category is a string here. It could be more than a string (ex. an object)
Keywords parameters : Keywords parameters :
- strict_membership: if we want strict membership checking - strict_membership: if we want strict membership checking
- strict : alias for strict_membership (deprecated but still here for - strict : alias for strict_membership (deprecated but still here for
skins backward compatibility. ) skins backward compatibility. )
XXX - there should be 2 different methods, one which acuiqred XXX - there should be 2 different methods, one which acuiqred
and the other which does not. A complete review of and the other which does not. A complete review of
the use of isMemberOf is required the use of isMemberOf is required
...@@ -1077,7 +1077,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1077,7 +1077,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
if c == category: if c == category:
return 1 return 1
else: else:
for c in self.getAcquiredCategoryMembershipList(context, base_category = base_category): for c in self.getAcquiredCategoryMembershipList(context, base_category = base_category):
if c.find(category) == 0: if c.find(category) == 0:
# The names begin with the same string # The names begin with the same string
c_right_split = c.split(category)[1] c_right_split = c.split(category)[1]
...@@ -1218,7 +1218,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1218,7 +1218,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
def updateRelatedContent(self, context, def updateRelatedContent(self, context,
previous_category_url, new_category_url): previous_category_url, new_category_url):
"""Updates related object when an object have moved. """Updates related object when an object have moved.
o context: the moved object o context: the moved object
o previous_category_url: the related url of this object before o previous_category_url: the related url of this object before
the move the move
...@@ -1273,7 +1273,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1273,7 +1273,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
""" """
strict_membership = kw.get('strict_membership', kw.get('strict', 0)) strict_membership = kw.get('strict_membership', kw.get('strict', 0))
portal_type = kw.get('portal_type') portal_type = kw.get('portal_type')
if isinstance(portal_type, str): if isinstance(portal_type, str):
portal_type = [portal_type] portal_type = [portal_type]
if spec is (): spec = None # We do not want to care about spec if spec is (): spec = None # We do not want to care about spec
...@@ -1289,12 +1289,12 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1289,12 +1289,12 @@ class CategoryTool( UniqueObject, Folder, Base ):
category_list = [] category_list = []
for base_category in base_category_list: for base_category in base_category_list:
category_list.append("%s/%s" % (base_category, context.getRelativeUrl())) category_list.append("%s/%s" % (base_category, context.getRelativeUrl()))
brain_result = self.Base_zSearchRelatedObjectsByCategoryList( brain_result = self.Base_zSearchRelatedObjectsByCategoryList(
category_list = category_list, category_list = category_list,
portal_type = portal_type, portal_type = portal_type,
strict_membership = strict_membership ) strict_membership = strict_membership )
result = [] result = []
for b in brain_result: for b in brain_result:
o = b.getObject() o = b.getObject()
...@@ -1305,7 +1305,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1305,7 +1305,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
# XXX missing filter and **kw stuff # XXX missing filter and **kw stuff
#return self.search_category(category_list = category_list, portal_type = spec) #return self.search_category(category_list = category_list, portal_type = spec)
# future implementation with brains, much more efficient # future implementation with brains, much more efficient
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getRelatedPropertyList' ) 'getRelatedPropertyList' )
def getRelatedPropertyList(self, context, base_category_list=None, def getRelatedPropertyList(self, context, base_category_list=None,
...@@ -1320,7 +1320,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1320,7 +1320,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
filter=filter, base=base, **kw) : filter=filter, base=base, **kw) :
result.append(o.getProperty(property_name, None)) result.append(o.getProperty(property_name, None))
return result return result
# SQL Expression Building # SQL Expression Building
security.declareProtected(Permissions.AccessContentsInformation, 'buildSQLSelector') security.declareProtected(Permissions.AccessContentsInformation, 'buildSQLSelector')
def buildSQLSelector(self, category_list, query_table='category'): def buildSQLSelector(self, category_list, query_table='category'):
...@@ -1395,7 +1395,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1395,7 +1395,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
else: else:
catalog_search = self.portal_catalog(portal_type = portal_type, catalog_search = self.portal_catalog(portal_type = portal_type,
selection_domain = selection_domain) selection_domain = selection_domain)
return catalog_search return catalog_search
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' )
...@@ -1404,7 +1404,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1404,7 +1404,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
This returns a list of items belonging to a category. This returns a list of items belonging to a category.
The following parameters are accepted : The following parameters are accepted :
portal_type : returns only objects from the given portal_type portal_type : returns only objects from the given portal_type
strict_membership : returns only object belonging to this category, not strict_membership : returns only object belonging to this category, not
objects belonging to child categories. objects belonging to child categories.
strict : a deprecated alias for strict_membership strict : a deprecated alias for strict_membership
""" """
...@@ -1418,14 +1418,14 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1418,14 +1418,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getCategoryMemberTitleItemList' ) 'getCategoryMemberTitleItemList' )
def getCategoryMemberTitleItemList(self, context, base_category = None, def getCategoryMemberTitleItemList(self, context, base_category = None,
spec = (), filter=None, portal_type=(), strict_membership = 0, spec = (), filter=None, portal_type=(), strict_membership = 0,
strict="DEPRECATED"): strict="DEPRECATED"):
""" """
This returns a title list of items belonging to a category This returns a title list of items belonging to a category
""" """
return self.getCategoryMemberItemList(self, context, base_category = base_category, return self.getCategoryMemberItemList(self, context, base_category = base_category,
spec = spec, filter=filter, portal_type=portal_type, spec = spec, filter=filter, portal_type=portal_type,
strict_membership = strict_membership, strict = strict, strict_membership = strict_membership, strict = strict,
display_id = 'getTitle') display_id = 'getTitle')
...@@ -1443,7 +1443,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1443,7 +1443,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
return cache[key] return cache[key]
except KeyError: except KeyError:
pass pass
try: try:
obj = self.restrictedTraverse(relative_url) obj = self.restrictedTraverse(relative_url)
if obj is None: if obj is None:
...@@ -1456,10 +1456,10 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1456,10 +1456,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
except (KeyError, AttributeError) : except (KeyError, AttributeError) :
LOG("CMFCategory WARNING",0,"Could not access object relative_url %s" % relative_url ) LOG("CMFCategory WARNING",0,"Could not access object relative_url %s" % relative_url )
value = None value = None
if cache is not None: if cache is not None:
cache[key] = value cache[key] = value
return value return value
InitializeClass( CategoryTool ) InitializeClass( CategoryTool )
......
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