[Erp5-report] r9585 - /erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 31 14:27:16 CEST 2006
Author: kevin
Date: Thu Aug 31 14:27:15 2006
New Revision: 9585
URL: http://svn.erp5.org?rev=9585&view=rev
Log:
WebSite_getDocumentValue returns the newest Version of a Document if it
is called with a reference (name parameter).
Modified:
erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml
Modified: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml?rev=9585&r1=9584&r2=9585&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml (original)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getDocumentValue.xml Thu Aug 31 14:27:15 2006
@@ -88,6 +88,9 @@
#\n
# NOTE: portal param probably useless\n
\n
+# Use the following Variable to determine which\n
+# \n
+\n
portal_catalog = portal.portal_catalog\n
\n
if name is None:\n
@@ -100,19 +103,31 @@
\n
#If name is not None, it has to be searched for it in the catalog.\n
\n
+# This Function helps do sort different Versions of the same Document.\n
+def compareVersion(c1, c2):\n
+ c1_value = c1.getObject() \n
+ c2_value = c2.getObject()\n
+ return cmp(c2_value.getVersion(), c1_value.getVersion()) \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, validation_state=\'published\')\n
if len(matching_document_list):\n
+ matching_document_list=list(matching_document_list)\n
+ matching_document_list.sort(compareVersion)\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
+ matching_document_list=list(matching_document_list)\n
+ matching_document_list.sort(compareVersion)\n
return matching_document_list[0].getObject()\n
# Then try to get any document\n
matching_document_list = portal_catalog(reference = \'%s\' % name)\n
if len(matching_document_list):\n
+ matching_document_list=list(matching_document_list)\n
+ matching_document_list.sort(compareVersion)\n
return matching_document_list[0].getObject()\n
return None \n
\n
@@ -171,6 +186,7 @@
<string>portal_catalog</string>
<string>None</string>
<string>context</string>
+ <string>compareVersion</string>
<string>getDocument</string>
</tuple>
</value>
More information about the Erp5-report
mailing list