From 26e713bbf15600f10deb4b49d847238c12fe1ed4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 26 Mar 2008 14:43:21 +0000
Subject: [PATCH] Optimisation to set delivery_mirror_section_url on the brain
 was not working on virtual hosting environment

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20152 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ctionModule_zGetAccountingTransactionList.xml | 16 ++++++----------
 .../AccountingTransaction_getThirdPartyUrl.xml   | 10 ++--------
 bt5/erp5_accounting/bt/revision                  |  2 +-
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
index d9e4eb0e25..f9a26f0f7b 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_zGetAccountingTransactionList.xml
@@ -360,6 +360,12 @@
               </object>
             </value>
         </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
         <item>
             <key> <string>allow_simple_one_argument_traversal</string> </key>
             <value>
@@ -636,11 +642,6 @@ destination_section_where_expression</string> </value>
           SELECT COUNT(DISTINCT uid) AS count FROM (\n
         <dtml-else>\n
           SELECT main.*,\n
-          <dtml-let portal="portal_url.getPortalObject()"\n
-                    substring_position="len(\'/\'.join(portal.getPhysicalPath()))+1"\n
-                    portal_absolute_url="portal.absolute_url(relative=1)">\n
-          ( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
-          </dtml-let>\n
           ( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
           ( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
           ( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
@@ -1300,11 +1301,6 @@ UNION\n
           SELECT COUNT(DISTINCT uid) AS count FROM (\n
         <dtml-else>\n
           SELECT main.*,\n
-          <dtml-let portal="portal_url.getPortalObject()"\n
-                    substring_position="len(\'/\'.join(portal.getPhysicalPath()))+1"\n
-                    portal_absolute_url="portal.absolute_url(relative=1)">\n
-          ( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
-          </dtml-let>\n
           ( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
           ( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
           ( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyUrl.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyUrl.xml
index 62608c63dd..c3daf7717e 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyUrl.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getThirdPartyUrl.xml
@@ -68,11 +68,6 @@
             <value> <string># XXX bad name: AccountingTransaction_getMirrorSectionUrl sounds more consistent\n
 view_name = \'Entity_viewAccountingTransactionList?reset:int=1\'\n
 \n
-try:\n
-  return \'/%s/%s\' % (context.delivery_mirror_section_url, view_name)\n
-except AttributeError:\n
-  pass\n
-\n
 if brain is not None:\n
   transaction = brain.getObject()\n
 else:\n
@@ -132,11 +127,10 @@ if mirror_section is not None:\n
                             <string>selection_name</string>
                             <string>kwd</string>
                             <string>view_name</string>
-                            <string>_getattr_</string>
-                            <string>context</string>
-                            <string>AttributeError</string>
                             <string>None</string>
+                            <string>_getattr_</string>
                             <string>transaction</string>
+                            <string>context</string>
                             <string>mirror_section</string>
                           </tuple>
                         </value>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index 06834d4380..e59f0632ab 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-657
\ No newline at end of file
+658
\ No newline at end of file
-- 
2.30.9