From 3121406aa31a5963cada1299cbb5ff5594663286 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Wed, 30 Aug 2006 17:31:49 +0000
Subject: [PATCH] (Stefan) WebSite_getDocumentValue is now be able to display
 any object with a refernce property.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9568 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_web/WebSite_getDocumentValue.xml       | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml
index 12453b63df..57616c9c69 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml
@@ -88,8 +88,7 @@
 #\n
 # NOTE: portal param probably useless\n
 \n
-\n
-portal_catalog = container.portal_catalog\n
+portal_catalog = portal.portal_catalog\n
 \n
 if name is None:\n
   if context.getPortalType() == \'Web Page\':\n
@@ -99,16 +98,20 @@ if name is None:\n
   else:\n
     return None\n
 \n
-#"else:" (mostly code from the old implementation)\n
+#If name is not None, it has to be searched for it in the catalog.\n
 \n
 #from Products.ERP5Type.Cache import CachingMethod\n
 def getDocument(name):\n
   # First try to get a published document\n
-  matching_document_list = portal_catalog(reference = \'%s\' % name, portal_type=(\'Web Page\',), validation_state=\'published\')\n
+  matching_document_list = portal_catalog(reference = \'%s\' % name, validation_state=\'published\')\n
+  if len(matching_document_list):\n
+    return matching_document_list[0].getObject()\n
+  # Then try to get a validated document (Product)\n
+  matching_document_list = portal_catalog(reference = \'%s\' % name, validation_state=\'validated\')\n
   if len(matching_document_list):\n
     return matching_document_list[0].getObject()\n
   # Then try to get any document\n
-  matching_document_list = portal_catalog(reference = \'%s\' % name, portal_type=(\'Web Page\',))\n
+  matching_document_list = portal_catalog(reference = \'%s\' % name)\n
   if len(matching_document_list):\n
     return matching_document_list[0].getObject()\n
   return None \n
@@ -136,7 +139,7 @@ return getDocument(name)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>portal=None, name=None</string> </value>
+            <value> <string>portal, name=None</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -165,7 +168,6 @@ return getDocument(name)\n
                             <string>portal</string>
                             <string>name</string>
                             <string>_getattr_</string>
-                            <string>container</string>
                             <string>portal_catalog</string>
                             <string>None</string>
                             <string>context</string>
@@ -183,7 +185,6 @@ return getDocument(name)\n
             <value>
               <tuple>
                 <none/>
-                <none/>
               </tuple>
             </value>
         </item>
-- 
2.30.9