Commit 9fc21412 authored by Kevin Deldycke's avatar Kevin Deldycke

2006-08-24 Stefan

* URLs work with and without virtual hosting.
* No duplicate entries in WebSection_getDocumentValueList() if a page is associated by aggregate and also in a relevant publication section.
* Problem with WebSection_getDocumentValueList() fixed (aggregated pages were not in the list form this context).
* Removed some context.log() entries.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9375 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c1c63800
...@@ -97,7 +97,7 @@ portal_catalog = container.portal_catalog\n ...@@ -97,7 +97,7 @@ portal_catalog = container.portal_catalog\n
\n \n
# First find the web section we are in\n # First find the web section we are in\n
current_node = context\n current_node = context\n
while not current_node.getPortalType() in (\'Web Section\', \'Web Site\', \'Domain\'):\n while not current_node.getPortalType() in (\'Web Section\', \'Web Site\'):\n
current_node = current_node.aq_parent\n current_node = current_node.aq_parent\n
\n \n
# Then find the publication categories referenced by the web section\n # Then find the publication categories referenced by the web section\n
...@@ -113,7 +113,7 @@ def checkMember(x):\n ...@@ -113,7 +113,7 @@ def checkMember(x):\n
return x\n return x\n
\n \n
# get all web pages and check if their publication category is in the category list of the web section\n # get all web pages and check if their publication category is in the category list of the web section\n
#reference_list = map(lambda x:x.getReference(), context.getSourceValueList(portal_type="Web Page"))\n # reference_list = map(lambda x:x.getReference(), context.getSourceValueList(portal_type="Web Page"))\n
reference_list = map(lambda x:x.getReference(), portal_catalog(portal_type=(\'Web Page\',)))\n reference_list = map(lambda x:x.getReference(), portal_catalog(portal_type=(\'Web Page\',)))\n
if reference_list:\n if reference_list:\n
li = filter(checkMember, list(context.portal_catalog(portal_type="Web Page")) )\n li = filter(checkMember, list(context.portal_catalog(portal_type="Web Page")) )\n
...@@ -121,17 +121,21 @@ if reference_list:\n ...@@ -121,17 +121,21 @@ if reference_list:\n
else:\n else:\n
my_list=[]\n my_list=[]\n
\n \n
if hasattr(context,\'getAggregateList\'):\n # get al web pages associated to the section by aggregate-relation\n
aggregate_values = context.getAggregateList()\n if hasattr(current_node,\'getAggregateList\'):\n
aggregate_values = current_node.getAggregateList()\n
aggregate_values = map(context.restrictedTraverse,aggregate_values)\n aggregate_values = map(context.restrictedTraverse,aggregate_values)\n
li.extend(aggregate_values) # this causes a crash\n li.extend(aggregate_values) \n
context.log("AVVVVVV",aggregate_values)\n
\n
\n \n
def abcd(x):\n # Remove Duplicate entries in my_list\n
return x#.getPortalType()\n my_clean_list=[]\n
my_reference_list=[]\n
for my_element in my_list:\n
if not my_element.getReference() in my_reference_list:\n
my_clean_list.append(my_element)\n
my_reference_list.append(my_element.getReference())\n
\n \n
return map(abcd,my_list)\n return my_clean_list\n
\n \n
\n \n
## FYI - old implementation - broken\n ## FYI - old implementation - broken\n
...@@ -244,7 +248,10 @@ return map(abcd,my_list)\n ...@@ -244,7 +248,10 @@ return map(abcd,my_list)\n
<string>my_list</string> <string>my_list</string>
<string>hasattr</string> <string>hasattr</string>
<string>aggregate_values</string> <string>aggregate_values</string>
<string>abcd</string> <string>my_clean_list</string>
<string>my_reference_list</string>
<string>_getiter_</string>
<string>my_element</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -68,9 +68,7 @@ ...@@ -68,9 +68,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string># This script is part of ERP5 Web\n
# This script is part of ERP5 Web\n
#\n #\n
# ERP5 Web is an extension to ERP5 which provides a way\n # ERP5 Web is an extension to ERP5 which provides a way\n
# to create web sites which can display selected\n # to create web sites which can display selected\n
...@@ -101,51 +99,22 @@ ...@@ -101,51 +99,22 @@
# NOTE: it is still unknown whether this script\n # NOTE: it is still unknown whether this script\n
# needs to be integrated or not to the absolute_url API\n # needs to be integrated or not to the absolute_url API\n
\n \n
# FYI old implementation\n
\n
# First build the main section URL\n # First build the main section URL\n
main_section = context\n main_section = context\n
main_section_path = None\n main_section_path = None\n
#while main_section_path is None and main_section is not None:\n while hasattr(main_section,\'aq_parent\') and hasattr(main_section,\'getPortalType\') and main_section.getPortalType()!="Web Section" and main_section.getPortalType()!="Web Site":\n
# if hasattr(main_section, \'getPortalType\'):\n
# if main_section.getPortalType() == \'Web Section\':\n
# main_section_path = str(main_section.getObject().absolute_url())\n
# elif main_section.getPortalType() == \'Web Site\':\n
# main_section_path = str(main_section.getObject().absolute_url())\n
# main_section = main_section.aq_parent\n
while hasattr(main_section,\'aq_parent\'):\n
main_section_path = str(main_section.absolute_url())\n main_section_path = str(main_section.absolute_url())\n
main_section = main_section.aq_parent\n main_section = main_section.aq_parent\n
\n \n
# then, if context is a web page, the reference must be added to the URL\n
my_reference=None\n
if hasattr(context,\'getReference\'):\n
my_reference = context.getReference()\n
if my_reference==None:\n
my_reference=""\n
\n \n
\n return main_section.absolute_url() + "/" + my_reference\n
# Then get the object\n </string> </value>
brain=None\n
if brain is None: brain=context\n
object = brain.getObject()\n
#if object is not None:\n
# if object.hasReference():\n
# reference = object.getReference()\n
# else:\n
# reference = None\n
#else:\n
# return ""\n
\n
#if reference:\n
# return "%s/%s" % (main_section_path, reference)\n
\n
if context.getPortalType()=="Web Page":\n
billl=context.WebSite_getBreadcrumbItemList()\n
billl=billl[1][1].WebSite_getDocumentUrl() #get the URL of the section\n
if context.getReference() is None:\n
return "ERROR: Reference-Attribute Missing for"+repr(context)\n
return billl+"/"+context.getReference()\n
#context.log("hello",context.title+"==>"+context.aq_parent.WebSite_getDocumentUrl()+"--"+context.aq_inner.getUrl()+"--"+context.aq_inner.absolute_url()+"--"+context.aq_parent.absolute_url())\n
\n
return "%s/%s" % (main_section_path, object.getRelativeUrl())\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -198,13 +167,9 @@ return "%s/%s" % (main_section_path, object.getRelativeUrl())\n ...@@ -198,13 +167,9 @@ return "%s/%s" % (main_section_path, object.getRelativeUrl())\n
<string>None</string> <string>None</string>
<string>main_section_path</string> <string>main_section_path</string>
<string>hasattr</string> <string>hasattr</string>
<string>str</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>brain</string> <string>str</string>
<string>object</string> <string>my_reference</string>
<string>billl</string>
<string>_getitem_</string>
<string>repr</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
2006-08-24 Stefan
* URLs work with and without virtual hosting.
* No duplicate entries in WebSection_getDocumentValueList() if a page is associated by aggregate and also in a relevant publication section.
* Problem with WebSection_getDocumentValueList() fixed (aggregated pages were not in the list form this context).
* Removed some context.log() entries.
2006-08-23 Stefan 2006-08-23 Stefan
* First rework of Web API scripts. * First rework of Web API scripts.
......
193 197
\ No newline at end of file \ No newline at end of file
0.3.2 0.3.3
\ No newline at end of file \ 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