From 52922b5ed549ce02b2fc74bc6b7a24c5146bbdf6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Wed, 21 Nov 2012 11:44:26 +0100
Subject: [PATCH] Revert both revert, as the original commits were just raising
 another bug but was not the cause of this bug

This reverts commit e89d10aa3a4c43468e74d70a77aeb31766f669ba.
This reverts commit ff1ca7039d565c4baa89118c1a1f890e1205d16e.
---
 ...akeOwnerTitleSearchQuery.catalog_keys.xml} |  0
 .../SQLCatalog_makeOwnerTitleSearchQuery.xml  | 77 +++++++++++++++++++
 .../z_related_owner_title.xml                 | 38 ---------
 .../related_key_list.xml                      |  1 -
 .../scriptable_key_list.xml                   |  3 +
 bt5/erp5_base/bt/revision                     |  2 +-
 .../bt/template_catalog_method_id_list        |  2 +-
 .../bt/template_catalog_related_key_list      |  1 -
 .../bt/template_catalog_scriptable_key_list   |  1 +
 9 files changed, 83 insertions(+), 42 deletions(-)
 rename bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/{z_related_owner_title.catalog_keys.xml => SQLCatalog_makeOwnerTitleSearchQuery.catalog_keys.xml} (100%)
 create mode 100644 bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.xml
 delete mode 100644 bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.xml
 create mode 100644 bt5/erp5_base/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
 create mode 100644 bt5/erp5_base/bt/template_catalog_scriptable_key_list

diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.catalog_keys.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.catalog_keys.xml
similarity index 100%
rename from bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.catalog_keys.xml
rename to bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.catalog_keys.xml
diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.xml
new file mode 100644
index 0000000000..122e75cee8
--- /dev/null
+++ b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery.xml
@@ -0,0 +1,77 @@
+<?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>from Products.ZSQLCatalog.SQLCatalog import SimpleQuery\n
+\n
+portal = context.getPortalObject()\n
+\n
+reference_list = [x.reference for x in\n
+                  portal.portal_catalog(SimpleQuery(reference=None,\n
+                                                    comparison_operator="is not"),\n
+                                        select_list=[\'reference\'],\n
+                                        portal_type="Person", title=value)]\n
+\n
+return SimpleQuery(owner=reference_list or -1)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>value</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>SQLCatalog_makeOwnerTitleSearchQuery</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.xml
deleted file mode 100644
index f1cd822395..0000000000
--- a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_owner_title.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <global name="SQL" module="Products.ZSQLMethods.SQL"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>arguments_src</string> </key>
-            <value> <string>table_0\r\n
-query_table</string> </value>
-        </item>
-        <item>
-            <key> <string>connection_id</string> </key>
-            <value> <string>erp5_sql_connection</string> </value>
-        </item>
-        <item>
-            <key> <string>id</string> </key>
-            <value> <string>z_related_owner_title</string> </value>
-        </item>
-        <item>
-            <key> <string>src</string> </key>
-            <value> <string encoding="cdata"><![CDATA[
-
-<dtml-var query_table>.owner = <dtml-var table_0>.reference\n
-AND <dtml-var table_0>.portal_type = \'Person\'
-
-]]></string> </value>
-        </item>
-        <item>
-            <key> <string>title</string> </key>
-            <value> <string></string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
diff --git a/bt5/erp5_base/CatalogRelatedKeyTemplateItem/related_key_list.xml b/bt5/erp5_base/CatalogRelatedKeyTemplateItem/related_key_list.xml
index 7c7d4f6b06..59d2ac3ede 100644
--- a/bt5/erp5_base/CatalogRelatedKeyTemplateItem/related_key_list.xml
+++ b/bt5/erp5_base/CatalogRelatedKeyTemplateItem/related_key_list.xml
@@ -3,7 +3,6 @@
  <key>child_telephone_SearchableText | catalog,full_text/SearchableText/z_related_child_telephone</key>
  <key>default_email_text | catalog,email/url_string/z_related_default_email</key>
  <key>destination_person_title | category,catalog/title/z_related_destination_person</key>
- <key>owner_title | catalog/title/z_related_owner_title</key>
  <key>related_resource_use_uid | category,category,catalog,catalog/uid/z_related_resource_use</key>
  <key>source_organisation_title | category,catalog/title/z_related_source_organisation</key>
  <key>source_person_title | category,catalog/title/z_related_source_person</key>
diff --git a/bt5/erp5_base/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml b/bt5/erp5_base/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
new file mode 100644
index 0000000000..1ae9c2d923
--- /dev/null
+++ b/bt5/erp5_base/CatalogScriptableKeyTemplateItem/scriptable_key_list.xml
@@ -0,0 +1,3 @@
+<key_list>
+ <key>owner_title | SQLCatalog_makeOwnerTitleSearchQuery</key>
+</key_list>
\ No newline at end of file
diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision
index 65bdad7fa2..9b5ad81b29 100644
--- a/bt5/erp5_base/bt/revision
+++ b/bt5/erp5_base/bt/revision
@@ -1 +1 @@
-1026
\ No newline at end of file
+1030
\ No newline at end of file
diff --git a/bt5/erp5_base/bt/template_catalog_method_id_list b/bt5/erp5_base/bt/template_catalog_method_id_list
index 97409d59ee..c52027b236 100644
--- a/bt5/erp5_base/bt/template_catalog_method_id_list
+++ b/bt5/erp5_base/bt/template_catalog_method_id_list
@@ -1,8 +1,8 @@
+erp5_mysql_innodb/SQLCatalog_makeOwnerTitleSearchQuery
 erp5_mysql_innodb/z_related_child_address
 erp5_mysql_innodb/z_related_child_telephone
 erp5_mysql_innodb/z_related_default_email
 erp5_mysql_innodb/z_related_destination_person
-erp5_mysql_innodb/z_related_owner_title
 erp5_mysql_innodb/z_related_resource_use
 erp5_mysql_innodb/z_related_source_organisation
 erp5_mysql_innodb/z_related_source_person
\ No newline at end of file
diff --git a/bt5/erp5_base/bt/template_catalog_related_key_list b/bt5/erp5_base/bt/template_catalog_related_key_list
index e5085168fa..95319495c6 100644
--- a/bt5/erp5_base/bt/template_catalog_related_key_list
+++ b/bt5/erp5_base/bt/template_catalog_related_key_list
@@ -3,6 +3,5 @@ source_person_title | category,catalog/title/z_related_source_person
 destination_person_title | category,catalog/title/z_related_destination_person
 default_email_text | catalog,email/url_string/z_related_default_email
 related_resource_use_uid | category,category,catalog,catalog/uid/z_related_resource_use
-owner_title | catalog/title/z_related_owner_title
 child_address_SearchableText | catalog,full_text/SearchableText/z_related_child_address
 child_telephone_SearchableText | catalog,full_text/SearchableText/z_related_child_telephone
\ No newline at end of file
diff --git a/bt5/erp5_base/bt/template_catalog_scriptable_key_list b/bt5/erp5_base/bt/template_catalog_scriptable_key_list
new file mode 100644
index 0000000000..976c4e353d
--- /dev/null
+++ b/bt5/erp5_base/bt/template_catalog_scriptable_key_list
@@ -0,0 +1 @@
+owner_title | SQLCatalog_makeOwnerTitleSearchQuery
\ No newline at end of file
-- 
2.30.9