[Erp5-report] r34245 luke - /erp5/trunk/products/ERP5/Tool/TemplateTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Apr 1 15:14:01 CEST 2010
Author: luke
Date: Thu Apr 1 15:13:58 2010
New Revision: 34245
URL: http://svn.erp5.org?rev=34245&view=rev
Log:
- implement simple method to automatically install required list of Business Templates from repositories
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=34245&r1=34244&r2=34245&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] Thu Apr 1 15:13:58 2010
@@ -992,4 +992,41 @@
return 0
+ def _getBusinessTemplateUrlDict(self):
+ business_template_url_dict = {}
+ for bt in self.getRepositoryBusinessTemplateList():
+ url, name = self.decodeRepositoryBusinessTemplateUid(bt.getUid())
+ business_template_url_dict[name[:-4]] = {
+ 'url': '%s/%s' % (url, name),
+ 'revision': bt.getRevision()
+ }
+ return business_template_url_dict
+
+ security.declareProtected(Permissions.ManagePortal,
+ 'installBusinessTemplatesFromRepositories' )
+ def installBusinessTemplatesFromRepositories(self, template_list,
+ only_newer=True):
+ """Installs template_list from configured repositories by default only newest"""
+ # XXX-Luke: This method could replace
+ # TemplateTool_installRepositoryBusinessTemplateList while still being
+ # possible to reuse by external callers
+ opreation_log = []
+ template_dict = self._getBusinessTemplateUrlDict()
+ for template_name in template_list:
+ if template_name in template_dict:
+ installed_bt = self.getInstalledBusinessTemplate(template_name)
+ if installed_bt is None or not only_newer or \
+ installed_bt.getRevision() < template_dict[
+ template_name]['revision']:
+ template_document = self.download(template_dict[template_name][
+ 'url'])
+ template_document.install()
+ opreation_log.append('Installed %s with revision %s' % (
+ template_document.getTitle(), template_document.getRevision()))
+ else:
+ opreation_log.append('Skipped %s' % template_name)
+ else:
+ opreation_log.append('Not found in repositories %s' % template_name)
+ return opreation_log
+
InitializeClass(TemplateTool)
More information about the Erp5-report
mailing list