Commit ac9b485c authored by Sebastien Robin's avatar Sebastien Robin

core: avoid long urls with Base_jumpToRelatedObject

when script was called with "related=False", and when there was too many objects, then
a very long list of uid was given in url, and this could be truncated by web browser or web servers.
This was generating errors.

So instead, store the list of uids in the selection.
parent 1d2b6029
......@@ -112,18 +112,25 @@ else:\n
if len(portal_type) == 1:\n
module_id = portal.getDefaultModuleId(portal_type[0], None)\n
if module_id is not None:\n
module = portal.getDefaultModule(portal_type[0])\n
if related:\n
return portal.getDefaultModule(portal_type[0]).Base_redirect(\n
return module.Base_redirect(\n
\'view\', keep_items={\'default_%s_uid\' % base_category: relation.getUid(),\n
\'ignore_hide_rows\': 1,\n
\'reset\': 1})\n
# We can not pass parameters through url, otherwise we might have too long urls (if many uids).\n
# Therefore check if we are in usual case of module form having a listbox, and update\n
# selection for it\n
get_uid_method = getattr(relation, \'get%sUidList\' % getter_base_name)\n
return context.getPortalObject().getDefaultModule(portal_type[0]).Base_redirect(\n
\'view\', keep_items=dict(\n
reset=1,\n
ignore_hide_rows=1,\n
uid=get_uid_method(portal_type=portal_type,\n
checked_permission=\'View\')))\n
portal_type_object = portal.portal_types[module.getPortalType()]\n
module_form = portal_type_object.getDefaultViewFor(module)\n
if "listbox" in [x for x in module_form.objectIds()]:\n
listbox = module_form.listbox\n
selection_name = listbox.get_value("selection_name")\n
portal.portal_selections.setSelectionToAll(selection_name)\n
uid_list = get_uid_method(portal_type=portal_type, checked_permission="View")\n
portal.portal_selections.setSelectionParamsFor(selection_name, {"uid": uid_list})\n
return module.Base_redirect(\'view\', keep_items=dict(ignore_hide_rows=1))\n
\n
# compute the list of objects we are actually authorised to view\n
related_object_list = []\n
......
......@@ -588,7 +588,8 @@ class ERP5TypeInformation(XMLObject,
search_source_list += self.getTypeBaseCategoryList()
return ' '.join(filter(None, search_source_list))
security.declarePrivate('getDefaultViewFor')
security.declareProtected(Permissions.AccessContentsInformation,
'getDefaultViewFor')
def getDefaultViewFor(self, ob, view='view'):
"""Return the object that renders the default view for the given object
"""
......
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