From 0e0f2f227e3328ff00ba2e5d705b1a815c2e0877 Mon Sep 17 00:00:00 2001 From: Fabien Morin <fabien@nexedi.com> Date: Tue, 2 Feb 2010 13:03:26 +0000 Subject: [PATCH] 2010-02-02 fabien * remove WebSection_getPermanentURLForView which was bad (see bug #1507) and use getPermanentUrl() from WebSection.py. * WebSection_getPermanentUrl script is not used anymore (and should never be used, it should be called only by getPermanentUrl() from WebSection.py). Now by default, getPermanentUrl(document) always return a link to html content. If you want to get a link to a file (ie. openoffice document, pdf document, ...) you should explicitly specify it : getPermanentUrl(document, view=False) Reviewed by Kazuhiko git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32176 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../erp5_web/WebSection_getPermanentURL.xml | 26 +++- .../WebSection_getPermanentURLForView.xml | 137 ------------------ .../erp5_web/WebSection_getSiteMapTree.xml | 2 +- .../listbox_link.xml | 2 +- .../erp5_web_widget_library/breadcrumb.xml | 2 +- .../section_content_render.xml | 2 +- bt5/erp5_web/bt/change_log | 5 + bt5/erp5_web/bt/revision | 2 +- 8 files changed, 32 insertions(+), 146 deletions(-) delete mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURLForView.xml diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURL.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURL.xml index 4e94f56002..7e63d0a378 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURL.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURL.xml @@ -80,6 +80,9 @@ document reference.\n \n The document parameter is required.\n +\n + If view is True, the url returned point to html content and can be opened in\n + a browser (ie. + \'/view\' for ooo documents)\n \n More sophisticated behaviours are possible.\n \n @@ -91,9 +94,14 @@ - change the behaviour of WebSection_getPermanentURL\n for documents which are not published.\n """\n +html_portal_type_list = (\'Web Site\', \'Web Section\', \'Web Page\')\n +portal_type = document.getPortalType()\n +\n # If no reference is defined, no way to build a permanent URL.\n reference = document.getReference()\n if not reference:\n + if view and portal_type not in html_portal_type_list:\n + return \'%s/view\' % document.absolute_url()\n return document.absolute_url()\n \n # Return absolute URL if this is not an appropriate portal_type\n @@ -101,15 +109,21 @@ portal = context.getPortalObject()\n valid_portal_type_list = portal.getPortalDocumentTypeList()\n portal_type = document.getPortalType()\n if portal_type not in valid_portal_type_list:\n + if view and portal_type not in html_portal_type_list:\n + return \'%s/view\' % document.absolute_url()\n return document.absolute_url()\n \n # Return absolute URL if this is not a \'live\' document\n validation_state = (\'released\', \'released_alive\', \'published\', \'published_alive\',\n \'shared\', \'shared_alive\', \'public\', \'validated\')\n if document.getValidationState() not in validation_state:\n + if view and portal_type not in html_portal_type_list:\n + return \'%s/view\' % document.absolute_url()\n return document.absolute_url()\n \n # Return the URL\n +if view and portal_type not in html_portal_type_list:\n + return \'%s/%s/view\' % (context.absolute_url(), reference)\n return "%s/%s" % (context.absolute_url(), reference)\n </string> </value> </item> @@ -121,7 +135,7 @@ return "%s/%s" % (context.absolute_url(), reference)\n </item> <item> <key> <string>_params</string> </key> - <value> <string>document</string> </value> + <value> <string>document, view=True</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -141,19 +155,21 @@ return "%s/%s" % (context.absolute_url(), reference)\n <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>1</int> </value> + <value> <int>2</int> </value> </item> <item> <key> <string>co_varnames</string> </key> <value> <tuple> <string>document</string> + <string>view</string> + <string>html_portal_type_list</string> <string>_getattr_</string> + <string>portal_type</string> <string>reference</string> <string>context</string> <string>portal</string> <string>valid_portal_type_list</string> - <string>portal_type</string> <string>validation_state</string> </tuple> </value> @@ -166,7 +182,9 @@ return "%s/%s" % (context.absolute_url(), reference)\n <item> <key> <string>func_defaults</string> </key> <value> - <none/> + <tuple> + <int>1</int> + </tuple> </value> </item> <item> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURLForView.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURLForView.xml deleted file mode 100644 index ce4e750862..0000000000 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getPermanentURLForView.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <tuple> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - <tuple/> - </tuple> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>Script_magic</string> </key> - <value> <int>3</int> </value> - </item> - <item> - <key> <string>_bind_names</string> </key> - <value> - <object> - <klass> - <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>_asgns</string> </key> - <value> - <dictionary> - <item> - <key> <string>name_container</string> </key> - <value> <string>container</string> </value> - </item> - <item> - <key> <string>name_context</string> </key> - <value> <string>context</string> </value> - </item> - <item> - <key> <string>name_m_self</string> </key> - <value> <string>script</string> </value> - </item> - <item> - <key> <string>name_subpath</string> </key> - <value> <string>traverse_subpath</string> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>_body</string> </key> - <value> <string>"""\n - return permanent url with "/view" add the end of the url for all portal_type\n - different from Web Page (Web Page can be displayed without "/view" and it\'s\n - better for cache).\n -"""\n -permanent_url = context.WebSection_getPermanentURL(document)\n -\n -# for web page, foo and foo/view are completely same\n -portal_type = document.getPortalType()\n -if portal_type == \'Web Page\':\n - return permanent_url\n -else:\n - return "%s/view" % permanent_url\n -</string> </value> - </item> - <item> - <key> <string>_code</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>_params</string> </key> - <value> <string>document</string> </value> - </item> - <item> - <key> <string>errors</string> </key> - <value> - <tuple/> - </value> - </item> - <item> - <key> <string>func_code</string> </key> - <value> - <object> - <klass> - <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>co_argcount</string> </key> - <value> <int>1</int> </value> - </item> - <item> - <key> <string>co_varnames</string> </key> - <value> - <tuple> - <string>document</string> - <string>_getattr_</string> - <string>context</string> - <string>permanent_url</string> - <string>portal_type</string> - </tuple> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>func_defaults</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>WebSection_getPermanentURLForView</string> </value> - </item> - <item> - <key> <string>warnings</string> </key> - <value> - <tuple/> - </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getSiteMapTree.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getSiteMapTree.xml index 8587e1f93e..2c4dc9f39c 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getSiteMapTree.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getSiteMapTree.xml @@ -117,7 +117,7 @@ def getSiteMapItemTree(section, depth=0, level=None): \n if default_document is not None and default_document.getPhysicalPath() == document.getPhysicalPath():\n continue\n result.append({\n - \'url\' : section.WebSection_getPermanentURLForView(document),\n + \'url\' : section.getPermanentURL(document),\n \'level\' : level,\n \'section\' : None,\n \'document\' : document,\n diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewContentListAsRSS/listbox_link.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewContentListAsRSS/listbox_link.xml index b0f8c2db22..6e33ae12de 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewContentListAsRSS/listbox_link.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewContentListAsRSS/listbox_link.xml @@ -273,7 +273,7 @@ <dictionary> <item> <key> <string>_text</string> </key> - <value> <string>python:cell.WebSection_getPermanentURLForView(cell)</string> </value> + <value> <string>python:cell.getPermanentURL(cell)</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/breadcrumb.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/breadcrumb.xml index 02d3d2733b..b8bfebba1b 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/breadcrumb.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/breadcrumb.xml @@ -49,7 +49,7 @@ tal:condition="remaining_items">\n <li tal:define="current_item python: remaining_items[0];\n remaining_items python: remaining_items[1:]">\n - <a tal:attributes="href python: \'%s/view\' % current_item[1].getPermanentURL(current_item[1]);\n + <a tal:attributes="href python: current_item[1].getPermanentURL(current_item[1]);\n class python: len(remaining_items) == 0 and \'selected\' or \'\'"\n tal:content="python: current_item[0]"/>\n <tal:block metal:use-macro="here/breadcrumb/macros/renderBreadcrumbItem"/>\n diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/section_content_render.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/section_content_render.xml index a6d96a3160..a3cd4329c2 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/section_content_render.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/section_content_render.xml @@ -46,7 +46,7 @@ </tal:block>\n \n <ul tal:repeat="document python:here.getDocumentValueList()">\n - <li><a tal:attributes="href python:here.WebSection_getPermanentURLForView(document)"\n + <li><a tal:attributes="href python:here.getPermanentUrl(document)"\n tal:content="python: document.getProperty(\'translated_short_title\', None)\n or document.getTranslatedTitleOrId()"/></li>\n </ul>\n diff --git a/bt5/erp5_web/bt/change_log b/bt5/erp5_web/bt/change_log index bcd458afb3..eecdd5b5f0 100644 --- a/bt5/erp5_web/bt/change_log +++ b/bt5/erp5_web/bt/change_log @@ -1,3 +1,8 @@ +2010-02-02 fabien +* remove WebSection_getPermanentURLForView which was bad (see bug #1507) and use getPermanentUrl() from WebSection.py. +* WebSection_getPermanentUrl script is not used anymore (and should never be used, it should be called only by getPermanentUrl() from WebSection.py). Now by default, getPermanentUrl(document) always return a link to html content. If you want to get a link to a file (ie. openoffice document, pdf document, ...) you should explicitly specify it : +getPermanentUrl(document, view=False) + 2010-01-22 nicolas * Update configuration of Caching Policy Manager to fill Last-Modified Header with modification_date. * Web Site and Web Section are not using Caching Policy Manager diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision index 0735b8030c..7bfae052e1 100644 --- a/bt5/erp5_web/bt/revision +++ b/bt5/erp5_web/bt/revision @@ -1 +1 @@ -904 \ No newline at end of file +905 \ No newline at end of file -- 2.30.9