From 3989fee169bd4fa2b49f7f3e1b823f657a974ea5 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Thu, 21 Jun 2007 15:38:55 +0000
Subject: [PATCH] Add some utility scripts for getting list of root Web
 Sections for a Web Site and root Web Section for a document. This scripts can
 be used to create site navigation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14915 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_web/WebSite_getMainSection.xml       | 180 ++++++++++++++++++
 .../erp5_web/WebSite_getMainSectionList.xml   | 162 ++++++++++++++++
 bt5/erp5_web/bt/revision                      |   2 +-
 3 files changed, 343 insertions(+), 1 deletion(-)
 create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSection.xml
 create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSectionList.xml

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSection.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSection.xml
new file mode 100644
index 0000000000..f243d0bfc2
--- /dev/null
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSection.xml
@@ -0,0 +1,180 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </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
+  Returns the section this document is part. \n
+  When selecting the section we return the highest \n
+  possible root section the current document belongs to.\n
+  So if  we have:\n
+    - \'WebSite/S1/S2/S3/Document1\'\n
+  script will return \'S1\'\n
+\n
+  This script is used to generate the menus.\n
+"""\n
+site = context.getWebSiteValue()\n
+section = context.getWebSectionValue()\n
+\n
+# document isn\'t part of section but accessed from the root of the site\n
+if section is site: \n
+  return None\n
+\n
+# This document is part of a section. Look for all parents and\n
+# return the last one before the site root\n
+current_section = section\n
+while current_section.getPortalType() != "Web Site":\n
+  section = current_section\n
+  current_section = current_section.getParentValue()\n
+return section\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></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>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>site</string>
+                            <string>section</string>
+                            <string>None</string>
+                            <string>current_section</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>WebSite_getMainSection</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Return the highest possible root section  for the current document</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/WebSite_getMainSectionList.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSectionList.xml
new file mode 100644
index 0000000000..5d360de4d2
--- /dev/null
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getMainSectionList.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </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
+  Returns the list of alls visible Web Sections for Web Site.\n
+  This script is used to generate the memus.\n
+"""\n
+site = context.getWebSiteValue()\n
+section_list = site.objectValues(portal_type = \'Web Section\', sort_on=\'int_index\')\n
+return filter(lambda x: x.isVisible(), section_list)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></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>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>site</string>
+                            <string>section_list</string>
+                            <string>filter</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>WebSite_getMainSectionList</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Get sorted main Web Sections for Web Site</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision
index 7f509bf389..245d3cfbf3 100644
--- a/bt5/erp5_web/bt/revision
+++ b/bt5/erp5_web/bt/revision
@@ -1 +1 @@
-560
\ No newline at end of file
+561
\ No newline at end of file
-- 
2.30.9