[Erp5-report] r39102 vincent - /erp5/trunk/products/ERP5/Tool/TemplateTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Oct 13 15:31:07 CEST 2010
Author: vincent
Date: Wed Oct 13 15:31:03 2010
New Revision: 39102
URL: http://svn.erp5.org?rev=39102&view=rev
Log:
Simplify getInstalledBusinessTemplate.
No need to accumulate a list to just return a single element based on a value
known during iteration.
No need for multiple return.
Modified:
erp5/trunk/products/ERP5/Tool/TemplateTool.py
Modified: erp5/trunk/products/ERP5/Tool/TemplateTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TemplateTool.py?rev=39102&r1=39101&r2=39102&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] Wed Oct 13 15:31:03 2010
@@ -120,20 +120,19 @@ class TemplateTool (BaseTool):
# However, that unlikely happens, and using a Z SQL Method has a
# potential danger because business templates may exchange catalog
# methods, so the database could be broken temporarily.
- replaced_list = []
- replaced_list_append = replaced_list.append
+ latest_bt = None
+ latest_revision = 0
for bt in self.contentValues(filter={'portal_type':'Business Template'}):
if bt.getTitle() == title:
installation_state = bt.getInstallationState()
if installation_state == 'installed':
- return bt
+ latest_bt = bt
+ break
elif strict is False and installation_state == 'replaced':
- replaced_list_append((bt.getId(), bt.getRevision()))
- # still there means that we might search for a replaced bt
- if len(replaced_list):
- replaced_list.sort(key=lambda x: -int(x[1]))
- return self._getOb(replaced_list[0][0])
- return None
+ revision = int(bt.getRevision())
+ if revision > latest_revision:
+ latest_bt = bt
+ return latest_bt
def getInstalledBusinessTemplatesList(self):
"""Deprecated.
More information about the Erp5-report
mailing list