Commit 80fdcbd6 authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_core: vary module item list cache key according to absolute_url_path

The getModuleItemList function should not cache absolute_url_path as it
may vary according to where the script is called from. Here we generate
the cache key to also vary according to the same condition as the module
absolute_url_path results.

_portal_url_  _________called_from_url_________ -> __portal_url_VirtualRootPhysicalPath___  ________module.absolute_url_path_______  _result_
/erp5         /erp5/...                            /erp5                                    /erp5/my_module                          OK
/erp5         /erp5/web_site_module/my_site/...    /erp5                                    /erp5/web_site_module/my_site/my_module  BAD
/erp5/        /erp5/web_site_module/my_site/...    /erp5/web_site_module/my_site            /erp5/web_site_module/my_site/my_module  OK
parent e1549361
......@@ -16,8 +16,18 @@ def getModuleItemList(user=None):
item_list.sort(key=lambda x: x[0])
return item_list
# XXX The getModuleItemList function should not cache absolute_url_path as it
# may vary according to where the script is called from. Here we generate
# the cache key to also vary according to the same condition as the module
# absolute_url_path results.
request = getattr(context, "REQUEST", None)
if request is not None:
virtual_root_url = request.physicalPathToURL(portal.getPhysicalPath() + ("",)) # ends with a slash
else:
virtual_root_url = portal.portal_url() # does not end with a slash
getModuleItemList = CachingMethod(getModuleItemList,
id=('ERP5Site_getModuleItemList', portal.Localizer.get_selected_language(), portal.portal_url()),
id=('ERP5Site_getModuleItemList', portal.Localizer.get_selected_language(), virtual_root_url),
cache_factory='erp5_ui_short')
return getModuleItemList(user=user)
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