Commit 71744029 authored by Kevin Deldycke's avatar Kevin Deldycke

Updated version (by Stefan)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9366 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f1e38201
...@@ -94,7 +94,6 @@ ...@@ -94,7 +94,6 @@
# in each section if necessary\n # in each section if necessary\n
\n \n
portal_catalog = container.portal_catalog\n portal_catalog = container.portal_catalog\n
# New implementation.\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
...@@ -105,7 +104,7 @@ while not current_node.getPortalType() in (\'Web Section\', \'Web Site\', \'Doma ...@@ -105,7 +104,7 @@ while not current_node.getPortalType() in (\'Web Section\', \'Web Site\', \'Doma
section_categories = current_node.getMembershipCriterionCategoryList()\n section_categories = current_node.getMembershipCriterionCategoryList()\n
\n \n
\n \n
def membercheck(x):\n def checkMember(x):\n
the_categories = x.getCategoriesList()\n the_categories = x.getCategoriesList()\n
if the_categories:\n if the_categories:\n
for the_category in the_categories:\n for the_category in the_categories:\n
...@@ -113,18 +112,26 @@ def membercheck(x):\n ...@@ -113,18 +112,26 @@ def membercheck(x):\n
if x.getValidationState()==\'published\':\n if x.getValidationState()==\'published\':\n
return x\n return x\n
\n \n
# this is just for debugging purposes, not used at the moment\n
def displaytitle(x):\n
return x.title\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(membercheck, list(context.portal_catalog(portal_type="Web Page")) )\n li = filter(checkMember, list(context.portal_catalog(portal_type="Web Page")) )\n
#li = map (displaytitle,li)\n my_list=li\n
return li\n else:\n
return "[] Empty reference_list"\n my_list=[]\n
\n
if hasattr(context,\'getAggregateList\'):\n
aggregate_values = context.getAggregateList()\n
aggregate_values = map(context.restrictedTraverse,aggregate_values)\n
li.extend(aggregate_values) # this causes a crash\n
context.log("AVVVVVV",aggregate_values)\n
\n
\n
def abcd(x):\n
return x#.getPortalType()\n
\n
return map(abcd,my_list)\n
\n \n
\n \n
## FYI - old implementation - broken\n ## FYI - old implementation - broken\n
...@@ -228,13 +235,16 @@ return "[] Empty reference_list"\n ...@@ -228,13 +235,16 @@ return "[] Empty reference_list"\n
<string>context</string> <string>context</string>
<string>current_node</string> <string>current_node</string>
<string>section_categories</string> <string>section_categories</string>
<string>membercheck</string> <string>checkMember</string>
<string>displaytitle</string>
<string>map</string> <string>map</string>
<string>reference_list</string> <string>reference_list</string>
<string>filter</string> <string>filter</string>
<string>list</string> <string>list</string>
<string>li</string> <string>li</string>
<string>my_list</string>
<string>hasattr</string>
<string>aggregate_values</string>
<string>abcd</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
...@@ -89,28 +87,22 @@ ...@@ -89,28 +87,22 @@
# language rather than the latest version in a different\n # language rather than the latest version in a different\n
# language)\n # language)\n
\n \n
nextsection=context\n next_section=context\n
while hasattr(nextsection,\'getParent\') and hasattr(nextsection,\'getPortalType\'):\n while hasattr(next_section,\'getParent\') and hasattr(next_section,\'getPortalType\'):\n
if nextsection.getPortalType() == \'Web Section\':\n if next_section.getPortalType() == \'Web Section\':\n
break\n break\n
else:\n else:\n
nextsection = nextsection.aq_parent\n next_section = next_section.aq_parent\n
context.log("krumb",nextsection)\n
\n \n
if not hasattr(next_section,\'getCategories\'):\n
return None # Context is not a Section, so no default Value available.\n
\n \n
if not hasattr(nextsection,\'getCategories\'):\n my_aggregate = next_section.getAggregateValue()\n
return None # Context is not a Section. Changed later\n if my_aggregate==None:\n
\n #context.log("No aggregate found","!!!")\n
context.log("Kontexttitle",context.title)\n
myaggregate = context.getAggregateValue()\n
context.log("My Aggegate => ",myaggregate)\n
if myaggregate==None:\n
context.log("No aggregate found","!!!")\n
return None\n return None\n
return myaggregate\n return my_aggregate\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -159,11 +151,11 @@ return myaggregate\n ...@@ -159,11 +151,11 @@ return myaggregate\n
<value> <value>
<tuple> <tuple>
<string>context</string> <string>context</string>
<string>nextsection</string> <string>next_section</string>
<string>hasattr</string> <string>hasattr</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>None</string> <string>None</string>
<string>myaggregate</string> <string>my_aggregate</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -137,7 +137,8 @@ object = brain.getObject()\n ...@@ -137,7 +137,8 @@ object = brain.getObject()\n
if context.getPortalType()=="Web Page":\n if context.getPortalType()=="Web Page":\n
billl=context.WebSite_getBreadcrumbItemList()\n billl=context.WebSite_getBreadcrumbItemList()\n
billl=billl[1][1].WebSite_getDocumentUrl() #get the URL of the section\n billl=billl[1][1].WebSite_getDocumentUrl() #get the URL of the section\n
context.log("bc",billl)\n if context.getReference() is None:\n
return "ERROR: Reference-Attribute Missing for"+repr(context)\n
return billl+"/"+context.getReference()\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 #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 \n
...@@ -203,6 +204,7 @@ return "%s/%s" % (main_section_path, object.getRelativeUrl())\n ...@@ -203,6 +204,7 @@ return "%s/%s" % (main_section_path, object.getRelativeUrl())\n
<string>object</string> <string>object</string>
<string>billl</string> <string>billl</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>repr</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
190 193
\ No newline at end of file \ No newline at end of file
0.3.1 0.3.2
\ 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