From a7308ec9c7497b73cbbee1cfe23f0443c32e0da1 Mon Sep 17 00:00:00 2001
From: Gabriel Monnerat <gabriel@tiolive.com>
Date: Wed, 22 Dec 2010 12:38:35 +0000
Subject: [PATCH] 2010-12-22 gabriel * Clean up the script to generate the UNG
 Domains and remove not used scripts.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41656 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../WebPageModule_generateDomain.xml          | 68 +++++++++--------
 ...eModule_getWebIllustrationListFiltered.xml | 74 -------------------
 .../WebPageModule_getWebPageListFiltered.xml  | 74 -------------------
 .../WebPageModule_getWebTableListFiltered.xml | 74 -------------------
 bt5/erp5_web_ung_theme/bt/change_log          |  3 +
 bt5/erp5_web_ung_theme/bt/revision            |  2 +-
 6 files changed, 40 insertions(+), 255 deletions(-)
 delete mode 100644 bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebIllustrationListFiltered.xml
 delete mode 100644 bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebPageListFiltered.xml
 delete mode 100644 bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebTableListFiltered.xml

diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_generateDomain.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_generateDomain.xml
index 27100a81ff..6af39fc20c 100644
--- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_generateDomain.xml
+++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_generateDomain.xml
@@ -55,18 +55,28 @@
   XXX - The generation of domains should be more dynamic because some domains is create manually.\n
 """\n
 \n
-def appendTempDomain(id, title, property_dict):\n
+def appendTempDomain(id, \n
+                     title,\n
+                     property_dict,\n
+                     parent=parent,\n
+                     membership_criterion_base_category=(),\n
+                     membership_criterion_category=()):\n
   domain = parent.generateTempDomain(id=id)\n
   domain.edit(title=title,\n
-              domain_generator_method_id = script.id)\n
+              domain_generator_method_id=script.id,\n
+              membership_criterion_base_category=membership_criterion_base_category,\n
+              membership_criterion_category=membership_criterion_category) \n
+\n
   domain.setCriterionPropertyList(property_dict.keys())\n
   for key, value in property_dict.items():\n
     domain.setCriterion(key, value)\n
-  domain_list.append(domain)\n
+\n
+  if parent.getId() == "ung_domain":\n
+    domain_list.append(domain)\n
   return domain\n
- \n
+\n
 domain_list = []\n
-validation_state_list = [\'draft\']\n
+validation_state_list = [\'draft\', \'published\', \'shared\']\n
 \n
 if depth == 1:\n
   return domain_list\n
@@ -89,7 +99,7 @@ appendTempDomain(\'owner_document_list\', \n
 \n
 appendTempDomain(\'shared_document_list\', \n
                  \'Shared by me\',\n
-                 dict(validation_state=validation_state_list))\n
+                 dict(validation_state=[\'shared\']))\n
 \n
 appendTempDomain(\'starred_document_list\',\n
                  \'Starred\',\n
@@ -104,27 +114,26 @@ domain = appendTempDomain(\'webpage_module_list\',\n
                           dict(portal_type=["Web Page", "Web Illustration", "Web Table"],\n
                                validation_state=validation_state_list))\n
 \n
-# XXX - Review code to be more dynamic\n
-webpage_subdomain = domain.generateTempDomain(id=\'subWebPage\')\n
-webpage_subdomain.edit(title="Web Page",\n
-             membership_criterion_base_category = ("webpage_module_list"),\n
-             membership_criterion_category = ("webpage_module_list"),\n
-             list_method=\'WebPageModule_getWebPageListFiltered\',\n
-             domain_generator_method_id=script.id)\n
-\n
-webtable_subdomain = domain.generateTempDomain(id=\'subWebTable\')\n
-webtable_subdomain.edit(title="Web Table",\n
-             membership_criterion_base_category = ("webpage_module_list"),\n
-             membership_criterion_category = ("webpage_module_list"),\n
-             list_method=\'WebPageModule_getWebTableListFiltered\',\n
-             domain_generator_method_id=script.id)\n
-\n
-webillustration_subdomain = domain.generateTempDomain(id=\'subWebIllustraion\')\n
-webillustration_subdomain.edit(title="Web Illustration",\n
-             membership_criterion_base_category = ("webpage_module_list"),\n
-             membership_criterion_category = ("webpage_module_list"),\n
-             list_method=\'WebPageModule_getWebIllustrationListFiltered\',\n
-             domain_generator_method_id=script.id)\n
+appendTempDomain(\'subWebPage\',\n
+                 \'Web Page\',\n
+                 dict(validation_state=validation_state_list, portal_type=["Web Page"]),\n
+                 domain,\n
+                 ("webpage_module_list",),\n
+                 ("webpage_module_list",))\n
+\n
+appendTempDomain(\'subWebTable\',\n
+                 \'Web Table\',\n
+                 dict(validation_state=validation_state_list, portal_type=["Web Table"]),\n
+                 domain,\n
+                 ("webpage_module_list",),\n
+                 ("webpage_module_list",))\n
+\n
+appendTempDomain(\'subWebIllustration\',\n
+                 \'Web Illustration\',\n
+                 dict(validation_state=validation_state_list, portal_type=["Web Illustration"]),\n
+                 domain,\n
+                 ("webpage_module_list",),\n
+                 ("webpage_module_list",))\n
 \n
 return domain_list\n
 </string> </value>
@@ -171,11 +180,6 @@ return domain_list\n
                             <string>validation_state_list</string>
                             <string>dict</string>
                             <string>domain</string>
-                            <string>_getattr_</string>
-                            <string>webpage_subdomain</string>
-                            <string>script</string>
-                            <string>webtable_subdomain</string>
-                            <string>webillustration_subdomain</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebIllustrationListFiltered.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebIllustrationListFiltered.xml
deleted file mode 100644
index 6f2bc7f97a..0000000000
--- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebIllustrationListFiltered.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </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
-  This script is used by domain to filter all Web Illustration objects except objects \n
-  with validation state == \'deleted\'.\n
-"""\n
-# XXX - the query should returns Web Illustration objects except validation_state == "deleted". \n
-# Try use Query or ComplexQuery object for it\n
-return context.portal_catalog(portal_type=["Web Illustration"], \n
-                              validation_state=["draft"])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>**kw</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>WebPageModule_getWebIllustrationListFiltered</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebPageListFiltered.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebPageListFiltered.xml
deleted file mode 100644
index 8c08790792..0000000000
--- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebPageListFiltered.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </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
-  This script is used by domain to filter all Web Page objects except objects \n
-  with validation state == \'deleted\'.\n
-"""\n
-# XXX - the query should returns Web Page objects except validation_state == "deleted". \n
-# Try use Query or ComplexQuery object for it\n
-return context.portal_catalog(portal_type=["Web Page"], \n
-                              validation_state=["draft"])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>**kw</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>WebPageModule_getWebPageListFiltered</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebTableListFiltered.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebTableListFiltered.xml
deleted file mode 100644
index be843bc37c..0000000000
--- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/WebPageModule_getWebTableListFiltered.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-    </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
-  This script is used by domain to filter all Web Table objects except objects \n
-  with validation state == \'deleted\'.\n
-"""\n
-# XXX - the query should returns Web Table objects except validation_state == "deleted". \n
-# Try use Query or ComplexQuery object for it\n
-return context.portal_catalog(portal_type=["Web Table"], \n
-                              validation_state=["draft"])\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_params</string> </key>
-            <value> <string>**kw</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>WebPageModule_getWebTableListFiltered</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_web_ung_theme/bt/change_log b/bt5/erp5_web_ung_theme/bt/change_log
index b8416431e1..8eadd77f4a 100644
--- a/bt5/erp5_web_ung_theme/bt/change_log
+++ b/bt5/erp5_web_ung_theme/bt/change_log
@@ -1,3 +1,6 @@
+2010-12-22 gabriel
+* Clean up the script to generate the UNG Domains and remove not used scripts.
+
 2010-12-20 gabriel
 * Added page to Login and script to Logout
 * Initial implementation to share documents in UNG.
diff --git a/bt5/erp5_web_ung_theme/bt/revision b/bt5/erp5_web_ung_theme/bt/revision
index 50f0bcd375..d55f9f7457 100644
--- a/bt5/erp5_web_ung_theme/bt/revision
+++ b/bt5/erp5_web_ung_theme/bt/revision
@@ -1 +1 @@
-135
\ No newline at end of file
+136
\ No newline at end of file
-- 
2.30.9