Commit 242a19b0 authored by Jérome Perrin's avatar Jérome Perrin

minor code cleanups


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14617 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 55a5ef2d
...@@ -29,13 +29,15 @@ ...@@ -29,13 +29,15 @@
from Products.CMFCategory.Filter import Filter from Products.CMFCategory.Filter import Filter
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zLOG import LOG from zLOG import LOG, PROBLEM
class Renderer(Filter): class Renderer(Filter):
""" """
Produces Item list out of category list Produces Item list out of category list
FIXME: translation FIXME: translation
( update: translation is not implemented in Renderer but in calling
methods, so maybe it should be removed from this API ? -jerome)
""" """
def __init__(self, spec = None, filter = None, portal_type = None, def __init__(self, spec = None, filter = None, portal_type = None,
...@@ -102,7 +104,6 @@ class Renderer(Filter): ...@@ -102,7 +104,6 @@ class Renderer(Filter):
""" """
#LOG('Renderer', 0, 'spec = %s, filter = %s, portal_type = %s, display_id = %s, sort_id = %s, display_method = %s, sort_method = %s, is_right_display = %s, translate_display = %s, translatation_domain = %s, base_category = %s, base = %s, display_none_category = %s, current_category = %s' % (repr(spec), repr(filter), repr(portal_type), repr(display_id), repr(sort_id), repr(display_method), repr(sort_method), repr(is_right_display), repr(translate_display), repr(translatation_domain), repr(base_category), repr(base), repr(display_none_category), repr(current_category)))
Filter.__init__(self, spec=spec, filter=filter, Filter.__init__(self, spec=spec, filter=filter,
portal_type=portal_type, filter_method=filter_method, portal_type=portal_type, filter_method=filter_method,
filter_node=filter_node, filter_leave=filter_leave) filter_node=filter_node, filter_leave=filter_leave)
...@@ -131,12 +132,8 @@ class Renderer(Filter): ...@@ -131,12 +132,8 @@ class Renderer(Filter):
""" """
Returns rendered items Returns rendered items
""" """
#LOG('render', 0, repr(self.filter))
#LOG('render', 10, repr(value_list))
value_list = self.getObjectList(value_list) value_list = self.getObjectList(value_list)
#LOG('render', 5, repr(value_list))
value_list = self.filter(value_list) value_list = self.filter(value_list)
#LOG('render', 10, repr(value_list))
if self.sort_method is not None: if self.sort_method is not None:
value_list.sort(self.sort_method) value_list.sort(self.sort_method)
elif self.sort_id is not None: elif self.sort_id is not None:
...@@ -172,11 +169,9 @@ class Renderer(Filter): ...@@ -172,11 +169,9 @@ class Renderer(Filter):
item_list.append(item) item_list.append(item)
if self.display_none_category: if self.display_none_category:
if self.is_right_display: if self.is_right_display:
#item = [None, ''] item = ['', '']
item = ['', ''] # XXX Formulator prefer '' to None.
else: else:
#item = ['', None] item = ['', '']
item = ['', ''] # XXX Formulator prefer '' to None.
item_list.append(item) item_list.append(item)
for value in value_list: for value in value_list:
...@@ -190,8 +185,8 @@ class Renderer(Filter): ...@@ -190,8 +185,8 @@ class Renderer(Filter):
except ConflictError: except ConflictError:
raise raise
except: except:
LOG('WARNING: Renderer', 0, LOG('CMFCategory', PROBLEM, 'Renderer was unable to call %s on %s'
'Unable to call %s on %s' % (self.display_id, value.getRelativeUrl())) % (self.display_id, value.getRelativeUrl()))
label = None label = None
else: else:
label = None label = None
...@@ -202,11 +197,11 @@ class Renderer(Filter): ...@@ -202,11 +197,11 @@ class Renderer(Filter):
# Prepend the specified base category to the url. # Prepend the specified base category to the url.
url = self.base_category + '/' + url url = self.base_category + '/' + url
else: else:
# If the base category of this category does not match the guessed base category, # If the base category of this category does not match the guessed
# merely ignore this category. # base category, merely ignore this category.
# This is not the job for a Renderer to automatically remove values if we don not # This is not the job for a Renderer to automatically remove values
# specify a filter # if we do not specify a filter
if not hasattr(value, 'getBaseCategoryId'): if getattr(value, 'getBaseCategoryId', None) is not None:
continue continue
# Remove from now, it might be outdated and useless # Remove from now, it might be outdated and useless
#if value.getBaseCategoryId() != guessed_base_category: #if value.getBaseCategoryId() != guessed_base_category:
...@@ -229,7 +224,7 @@ class Renderer(Filter): ...@@ -229,7 +224,7 @@ class Renderer(Filter):
bc = value.portal_categories.resolveCategory(self.base_category) bc = value.portal_categories.resolveCategory(self.base_category)
label = '%s/%s' % (bc.getTitleOrId(), label) label = '%s/%s' % (bc.getTitleOrId(), label)
else: else:
if hasattr(value, 'getBaseCategoryValue'): if getattr(value, 'getBaseCategoryValue', None) is not None:
bc = value.getBaseCategoryValue() bc = value.getBaseCategoryValue()
label = '%s/%s' % (bc.getTitleOrId(), label) label = '%s/%s' % (bc.getTitleOrId(), label)
......
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