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 @@
# in each section if necessary\n
\n
portal_catalog = container.portal_catalog\n
# New implementation.\n
\n
# First find the web section we are in\n
current_node = context\n
......@@ -105,7 +104,7 @@ while not current_node.getPortalType() in (\'Web Section\', \'Web Site\', \'Doma
section_categories = current_node.getMembershipCriterionCategoryList()\n
\n
\n
def membercheck(x):\n
def checkMember(x):\n
the_categories = x.getCategoriesList()\n
if the_categories:\n
for the_category in the_categories:\n
......@@ -113,18 +112,26 @@ def membercheck(x):\n
if x.getValidationState()==\'published\':\n
return x\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
#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
if reference_list:\n
li = filter(membercheck, list(context.portal_catalog(portal_type="Web Page")) )\n
#li = map (displaytitle,li)\n
return li\n
return "[] Empty reference_list"\n
li = filter(checkMember, list(context.portal_catalog(portal_type="Web Page")) )\n
my_list=li\n
else:\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
## FYI - old implementation - broken\n
......@@ -228,13 +235,16 @@ return "[] Empty reference_list"\n
<string>context</string>
<string>current_node</string>
<string>section_categories</string>
<string>membercheck</string>
<string>displaytitle</string>
<string>checkMember</string>
<string>map</string>
<string>reference_list</string>
<string>filter</string>
<string>list</string>
<string>li</string>
<string>my_list</string>
<string>hasattr</string>
<string>aggregate_values</string>
<string>abcd</string>
</tuple>
</value>
</item>
......
......@@ -68,9 +68,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# This script is part of ERP5 Web\n
<value> <string># This script is part of ERP5 Web\n
#\n
# ERP5 Web is an extension to ERP5 which provides a way\n
# to create web sites which can display selected\n
......@@ -89,28 +87,22 @@
# language rather than the latest version in a different\n
# language)\n
\n
nextsection=context\n
while hasattr(nextsection,\'getParent\') and hasattr(nextsection,\'getPortalType\'):\n
if nextsection.getPortalType() == \'Web Section\':\n
next_section=context\n
while hasattr(next_section,\'getParent\') and hasattr(next_section,\'getPortalType\'):\n
if next_section.getPortalType() == \'Web Section\':\n
break\n
else:\n
nextsection = nextsection.aq_parent\n
context.log("krumb",nextsection)\n
next_section = next_section.aq_parent\n
\n
if not hasattr(next_section,\'getCategories\'):\n
return None # Context is not a Section, so no default Value available.\n
\n
if not hasattr(nextsection,\'getCategories\'):\n
return None # Context is not a Section. Changed later\n
\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
my_aggregate = next_section.getAggregateValue()\n
if my_aggregate==None:\n
#context.log("No aggregate found","!!!")\n
return None\n
return myaggregate\n
]]></string> </value>
return my_aggregate\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -159,11 +151,11 @@ return myaggregate\n
<value>
<tuple>
<string>context</string>
<string>nextsection</string>
<string>next_section</string>
<string>hasattr</string>
<string>_getattr_</string>
<string>None</string>
<string>myaggregate</string>
<string>my_aggregate</string>
</tuple>
</value>
</item>
......
......@@ -137,7 +137,8 @@ object = brain.getObject()\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
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
#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
......@@ -203,6 +204,7 @@ return "%s/%s" % (main_section_path, object.getRelativeUrl())\n
<string>object</string>
<string>billl</string>
<string>_getitem_</string>
<string>repr</string>
</tuple>
</value>
</item>
......
190
\ No newline at end of file
193
\ No newline at end of file
0.3.1
\ No newline at end of file
0.3.2
\ 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