From ac9b485c5d3ebb5fabe49d3d55932a1c6fd2d2c8 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Wed, 24 Jun 2015 12:09:17 +0000 Subject: [PATCH] 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. --- .../erp5_core/Base_jumpToRelatedObject.xml | 21 ++++++++++++------- product/ERP5Type/ERP5Type.py | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_jumpToRelatedObject.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_jumpToRelatedObject.xml index 62ed10f87f..2f4e9524d6 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_jumpToRelatedObject.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_jumpToRelatedObject.xml @@ -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 diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index f26d8fadbd..6ea8bd90cd 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -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 """ -- 2.30.9