Commit 0e0f2f22 authored by Fabien Morin's avatar Fabien Morin

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
parent d1074720
......@@ -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>
......
<?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>
......@@ -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
......
......@@ -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>
......
......@@ -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
......
......@@ -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
......
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
......
904
\ No newline at end of file
905
\ No newline at end of file
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