Commit 717513af authored by Vincent Pelletier's avatar Vincent Pelletier

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39102 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c916b6cb
No related merge requests found
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment