Commit 8f531d96 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

clean up TradeModelPath.py.

* remove obsolete override of _getCategoryMembershipList() and _getAcquiredCategoryMembershipList().
* add comments in getArrowCategoryDict().
* improve the performance a bit.
parent cb3de52b
...@@ -163,50 +163,24 @@ class TradeModelPath(Path): ...@@ -163,50 +163,24 @@ class TradeModelPath(Path):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getArrowCategoryDict') 'getArrowCategoryDict')
def getArrowCategoryDict(self, context=None, **kw): # XXX-JPS do we need it in API ? def getArrowCategoryDict(self, context=None, **kw): # XXX-JPS do we need it in API ?
# This method returns the dict like
# {base_category_id:[category value url list], ...}
# for all Arrow base categories.
# Each category values are self's category values (if exist) or
# dynamically computed values (if not exist).
result = {} result = {}
dynamic_category_list = self._getDynamicCategoryList(context) dynamic_category_list = self._getDynamicCategoryList(context)
for base_category in self.getSourceArrowBaseCategoryList() +\ for base_category in self.getSourceArrowBaseCategoryList() +\
self.getDestinationArrowBaseCategoryList(): self.getDestinationArrowBaseCategoryList():
category_url_list = Path._getAcquiredCategoryMembershipList( category_url_list = self._getAcquiredCategoryMembershipList(
self, base_category, **kw) base_category, **kw)
if len(category_url_list) == 0 and context is not None: if len(category_url_list) == 0 and len(dynamic_category_list) > 0:
category_url_list = self._filterCategoryList(dynamic_category_list, category_url_list = self._filterCategoryList(dynamic_category_list,
base_category, **kw) base_category, **kw)
if len(category_url_list) > 0: if len(category_url_list) > 0:
result[base_category] = category_url_list result[base_category] = category_url_list
return result return result
# ICategoryAccessProvider overridden methods
def _getCategoryMembershipList(self, category, **kw):
"""
Overridden in order to take into account dynamic arrow categories in case if no static
categories are set on Trade Model Path
"""
context = kw.pop('context')
result = Path._getCategoryMembershipList(self, category, **kw)
if len(result) > 0:
return result
if context is not None:
dynamic_category_list = self._getDynamicCategoryList(context)
dynamic_category_list = self._filterCategoryList(dynamic_category_list, category, **kw)
result = dynamic_category_list
return result
def _getAcquiredCategoryMembershipList(self, category, **kw):
"""
Overridden in order to take into account dynamic arrow categories in case if no static
categories are set on Trade Model Path
"""
context = kw.pop('context', None)
result = Path._getAcquiredCategoryMembershipList(self, category, **kw)
if len(result) > 0:
return result
if context is not None:
dynamic_category_list = self._getDynamicCategoryList(context)
dynamic_category_list = self._filterCategoryList(dynamic_category_list, category, **kw)
result = dynamic_category_list
return result
def _filterCategoryList(self, category_list, category, spec=(), def _filterCategoryList(self, category_list, category, spec=(),
filter=None, portal_type=(), base=0, filter=None, portal_type=(), base=0,
keep_default=1, checked_permission=None): keep_default=1, checked_permission=None):
......
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