[Erp5-report] r36008 nicolas - in /erp5/trunk/buildout/local-eggs/erp5.recipe.installbusine...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 4 18:16:07 CEST 2010


Author: nicolas
Date: Fri Jun  4 18:16:06 2010
New Revision: 36008

URL: http://svn.erp5.org?rev=36008&view=rev
Log:
Recipe usefull to install business templates into erp5 instance
through XML-RPC transport.

Added:
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt   (with props)
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt   (with props)
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/setup.py
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/__init__.py
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/__init__.py
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/
    erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/__init__.py

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,8 @@
+Changelog
+=========
+
+0.1 (2010-06-03)
+----------------
+
+ - intial version
+   [nicolas]

Propchange: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/CHANGES.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,15 @@
+Business Templates installer through XML-RPC
+================================================
+
+Easy way to install Business Templates
+
+[install-business-templates]
+recipe = erp5.recipe.installbusinesstemplate
+repository_path = file://${bt5list:location}
+bt5_list = ${bt5list:bt5_urls}
+update_catalog = false
+protocol = http
+user = ${zope-instance:user}
+hostname = ${zope-instance:ip-address}
+port = ${zope-instance:http-address}
+portal_id = ${zope-instance:portal_id}

Propchange: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/setup.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/setup.py?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/setup.py (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/setup.py [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,39 @@
+# -*- coding: utf-8 -*-
+from setuptools import setup, find_packages
+
+name = "erp5.recipe.installbusinesstemplate"
+version = '0.1'
+
+def read(name):
+    return open(name).read()
+
+long_description=(
+        read('README.txt')
+        + '\n' +
+        read('CHANGES.txt')
+    )
+
+setup(
+    name = name,
+    version = version,
+    author = "Nicolas Delaby",
+    author_email = "nicolas at nexedi.com",
+    description = "ZC Buildout recipe to install easily BT5 from repository",
+    long_description=long_description,
+    license = "ZPL 2.1",
+    keywords = "zope2 buildout",
+    classifiers=[
+      "License :: OSI Approved :: Zope Public License",
+      "Framework :: Buildout",
+      "Framework :: Zope2",
+      ],
+    packages = find_packages('src'),
+    include_package_data = True,
+    package_dir = {'':'src'},
+    namespace_packages = ['erp5', 'erp5.recipe'],
+    #install_requires = [
+        #'infrae.subversion',
+    #],
+    zip_safe=False,
+    entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
+    )

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/__init__.py?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/__init__.py (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/__init__.py [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/__init__.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/__init__.py?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/__init__.py (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/__init__.py [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)

Added: erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/__init__.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/__init__.py?rev=36008&view=auto
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/__init__.py (added)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.installbusinesstemplate/src/erp5/recipe/installbusinesstemplate/__init__.py [utf8] Fri Jun  4 18:16:06 2010
@@ -1,0 +1,96 @@
+# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+import logging
+
+import xmlrpclib
+#import zc.buildout
+import zc.buildout.easy_install
+import zc.buildout.download
+import zc.recipe.egg
+import subprocess
+
+class Recipe(object):
+
+  MAX_BT_PER_TRANSACTION = 2
+
+  def __init__(self, buildout, name, options):
+    self.buildout, self.options, self.name = buildout, options, name
+    self.logger = logging.getLogger(self.name)
+    self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options)
+
+
+    options.setdefault('location', os.path.join(
+        buildout['buildout']['parts-directory'],
+        self.name,
+        ))
+
+    # Business Template installation
+    options.setdefault('repository_path', '')
+    options.setdefault('bt5_list', '')
+    options.setdefault('update_catalog', 'false')
+
+    # XML-RPC connection
+    options.setdefault('protocol', 'http')
+    options.setdefault('user', '')
+    options.setdefault('hostname', 'localhost')
+    options.setdefault('port', '8080')
+    options.setdefault('portal_id', 'erp5')
+
+  def _getConnectionString(self):
+    """Return connection string to connect
+    to instance
+    """
+    options = self.options
+    connection_string = '%(protocol)s://%(user)s@%(hostname)'\
+                        's:%(port)s/%(portal_id)s/' % options
+    return connection_string
+
+  def _getConnection(self, connection_string):
+    """Return XML-RPC connected object
+    """
+    connection =  xmlrpclib.ServerProxy(connection_string, allow_none=True)
+    return connection
+
+  def install(self):
+    options = self.options
+    location = options['location']
+    if not os.path.exists(location):
+      os.mkdir(location)
+
+    connection = self._getConnection(self._getConnectionString())
+    # install templates
+    repository_path = options['repository_path']
+    connection.portal_templates.updateRepositoryBusinessTemplateList(
+                                                       [repository_path], None)
+    bt5_list = [bt5 for bt5 in options['bt5_list'].splitlines() if bt5]
+    update_catalog = options['update_catalog'].lower() == 'true' or False
+    while bt5_list:
+      partial_bt5_list = bt5_list[:self.MAX_BT_PER_TRANSACTION]
+      print 'Installing following business template:',\
+                                                    ', '.join(partial_bt5_list)
+      result = connection.portal_templates\
+                 .installBusinessTemplatesFromRepositories(partial_bt5_list,
+                                                           True, update_catalog)
+
+      bt5_list = bt5_list[self.MAX_BT_PER_TRANSACTION:]
+
+    return [] # instance related recipe, it can be disaster to allow buildout
+              # to remove instances
+
+
+  update = install




More information about the Erp5-report mailing list