[Checkins] SVN: Products.GenericSetup/branches/1.4-with-global-zca/ backport usage of global ZCA instead of own registries

Godefroid Chapelle gotcha at bubblenet.be
Tue Mar 29 11:51:58 EDT 2011


Log message for revision 121157:
  backport usage of global ZCA instead of own registries
  
  add a buildout to run tests
  

Changed:
  _U  Products.GenericSetup/branches/1.4-with-global-zca/
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/interfaces.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/registry.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_registry.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_stepzcml.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_tool.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_zcml.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/upgrade.py
  U   Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/zcml.py
  A   Products.GenericSetup/branches/1.4-with-global-zca/bootstrap.py
  A   Products.GenericSetup/branches/1.4-with-global-zca/buildout.cfg

-=-

Property changes on: Products.GenericSetup/branches/1.4-with-global-zca
___________________________________________________________________
Modified: svn:ignore
   - *.egg-info

   + *.egg-info
bin
develop-eggs
eggs
parts
.installed.cfg


Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/interfaces.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/interfaces.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/interfaces.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -11,8 +11,6 @@
 #
 ##############################################################################
 """ GenericSetup product interfaces
-
-$Id$
 """
 
 from zope.interface import Attribute
@@ -20,7 +18,7 @@
 from zope.schema import Text
 from zope.schema import TextLine
 
-# Please note that these values may change. Always import 
+# Please note that these values may change. Always import
 # the values from here instead of using the values directly.
 BASE, EXTENSION = 1, 2
 SKIPPED_FILES = ('CVS', '.svn', '_svn', '_darcs')
@@ -70,7 +68,7 @@
 
     def listNotes():
         """ Return notes recorded by this context.
-        
+
         o Result a sequence of (component, message) tuples
         """
 
@@ -417,7 +415,7 @@
              relative (None for absolute paths).
 
           'type' -- either BASE or EXTENSION
-        
+
         o 'for_', if passed, should be the interface specifying the "site
             type" for which the profile is relevant, e.g.
             Products.CMFCore.interfaces.ISiteRoot or
@@ -428,7 +426,7 @@
     def listProfiles( for_=None ):
 
         """ Return a list of IDs for registered profiles.
-        
+
         o 'for_', if passed, should be the interface specifying the "site
             type" for which the profile is relevant, e.g.
             Products.CMFCore.interfaces.ISiteRoot or
@@ -441,7 +439,7 @@
         """ Return a list of mappings describing registered profiles.
 
         o See 'getProfileInfo' for a description of the mappings' keys.
-        
+
         o 'for_', if passed, should be the interface specifying the "site
             type" for which the profile is relevant, e.g.
             Products.CMFCore.interfaces.ISiteRoot or
@@ -464,7 +462,7 @@
 
         o If 'product' is passed, then 'path' should be interpreted as
           relative to the corresponding product directory.
-        
+
         o 'for_', if passed, should be the interface specifying the "site
           type" for which the profile is relevant, e.g.
           Products.CMFCore.interfaces.ISiteRoot or
@@ -797,7 +795,7 @@
     """
     def __call__():
         """ Return a string, suitable for looking up an IContentFactory.
-        
+
         o The string should allow finding a factory for our context's
           container which would create an "empty" instance of the same
           type as our context.
@@ -853,7 +851,7 @@
     def PUT(REQUEST, RESPONSE):
         """ Parse file content and update the object.
 
-        o 'REQUEST' will have a 'get' method, which will have the 
+        o 'REQUEST' will have a 'get' method, which will have the
           content object in its "BODY" key.  It will also have 'get_header'
           method, whose headers (e.g., "Content-Type") may affect the
           processing of the body.
@@ -882,3 +880,31 @@
 
     tool = Attribute("The tool which is performing the import")
 
+
+class IComponentsHandlerBlacklist(Interface):
+    """ Interface for named utilities which can exclude specified interfaces
+    from being handled by the components export and import handlers.
+    """
+
+    def getExcludedInterfaces():
+        """ Return a sequence of interfaces.
+
+        Objects providing any of the returned interfaces should be ignored by
+        the export and import handlers.
+        """
+
+class IProfile(Interface):
+    """ Named profile.
+    """
+
+class IImportStep(Interface):
+    """ Named import step.
+    """
+
+class IExportStep(Interface):
+    """ Named export step.
+    """
+
+class IUpgradeSteps(Interface):
+    """ Named upgrade steps.
+    """

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/registry.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/registry.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/registry.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -43,6 +43,7 @@
 #   XML parser
 #
 
+
 class _HandlerBase(ContentHandler):
 
     _MARKER = object()
@@ -226,12 +227,45 @@
 InitializeClass( _ExportStepRegistryParser )
 
 
+class GlobalRegistryStorage(object):
+
+    def __init__(self, interfaceClass):
+        self.interfaceClass = interfaceClass
+
+    def keys(self):
+        sm = getGlobalSiteManager()
+        keys = [name for name, info in sm.getUtilitiesFor(self.interfaceClass)]
+        return keys
+
+    def values(self):
+        sm = getGlobalSiteManager()
+        values = [info for name, info in sm.getUtilitiesFor(self.interfaceClass)]
+        return values
+
+    def get(self, key):
+        sm = getGlobalSiteManager()
+        return sm.queryUtility(provided=self.interfaceClass, name=key)
+
+    def __setitem__(self, id, info):
+        sm = getGlobalSiteManager()
+        return sm.registerUtility(info, provided=self.interfaceClass, name=id)
+
+    def __delitem__(self, id):
+        sm = getGlobalSiteManager()
+        return sm.unregisterUtility(provided=self.interfaceClass, name=id)
+
+    def clear(self):
+        for key in self.keys():
+            del self[key]
+
 class BaseStepRegistry( Implicit ):
 
     security = ClassSecurityInfo()
 
-    def __init__( self ):
-
+    def __init__( self, store=None ):
+        if store is None:
+            store = {}
+        self._registered = store
         self.clear()
 
     security.declareProtected( ManagePortal, 'listSteps' )
@@ -299,12 +333,12 @@
 
     security.declarePrivate( 'unregisterStep' )
     def unregisterStep( self, id ):
-        del self._registered[id]
+        del self._registered[ id ]
 
     security.declarePrivate( 'clear' )
     def clear( self ):
 
-        self._registered = {}
+        self._registered.clear()
 
     security.declarePrivate( 'parseXML' )
     def parseXML( self, text, encoding=None ):
@@ -453,7 +487,7 @@
 
 InitializeClass( ImportStepRegistry )
 
-_import_step_registry = ImportStepRegistry()
+_import_step_registry = ImportStepRegistry(GlobalRegistryStorage(IImportStep))
 
 class ExportStepRegistry( BaseStepRegistry ):
 
@@ -527,7 +561,7 @@
 
 InitializeClass( ExportStepRegistry )
 
-_export_step_registry = ExportStepRegistry()
+_export_step_registry = ExportStepRegistry(GlobalRegistryStorage(IExportStep))
 
 
 class ToolsetRegistry( Implicit ):
@@ -658,7 +692,7 @@
     security.setDefaultAccess( 'allow' )
 
     def __init__( self ):
-
+        self._registered = GlobalRegistryStorage(IProfile)
         self.clear()
 
     security.declareProtected( ManagePortal, 'getProfileInfo' )
@@ -666,7 +700,9 @@
 
         """ See IProfileRegistry.
         """
-        result = self._profile_info[ profile_id ]
+        result = self._registered.get(profile_id)
+        if result is None:
+            raise KeyError, profile_id
         if for_ is not None:
             if not issubclass( for_, result['for'] ):
                 raise KeyError, profile_id
@@ -678,7 +714,7 @@
         """ See IProfileRegistry.
         """
         result = []
-        for profile_id in self._profile_ids:
+        for profile_id in self._registered.keys():
             info = self.getProfileInfo( profile_id )
             if for_ is None or issubclass( for_, info['for'] ):
                 result.append( profile_id )
@@ -706,12 +742,10 @@
                        ):
         """ See IProfileRegistry.
         """
-        profile_id = '%s:%s' % (product or 'other', name)
-        if self._profile_info.get( profile_id ) is not None:
+        profile_id = self._computeProfileId(name, product)
+        if self._registered.get(profile_id) is not None:
             raise KeyError, 'Duplicate profile ID: %s' % profile_id
 
-        self._profile_ids.append( profile_id )
-
         info = { 'id' : profile_id
                , 'title' : title
                , 'description' : description
@@ -752,13 +786,21 @@
         # metadata.xml description trumps ZCML description... awkward
         info.update( metadata )
 
-        self._profile_info[ profile_id ] = info
+        self._registered[profile_id] = info
 
+    def _computeProfileId(self, name, product):
+        profile_id = '%s:%s' % (product or 'other', name)
+        return profile_id
+
+    security.declareProtected( ManagePortal, 'unregisterProfile' )
+    def unregisterProfile( self, name, product=None):
+        profile_id = self._computeProfileId(name, product)
+        del self._registered[profile_id]
+
     security.declarePrivate( 'clear' )
     def clear( self ):
+        self._registered.clear()
 
-        self._profile_info = {}
-        self._profile_ids = []
 
 InitializeClass( ProfileRegistry )
 

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_registry.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_registry.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_registry.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -1016,6 +1016,8 @@
                           , ConformsToIProfileRegistry
                           ):
 
+
+
     def _getTargetClass( self ):
 
         from Products.GenericSetup.registry import ProfileRegistry
@@ -1047,7 +1049,7 @@
                                 , PRODUCT
                                 , PROFILE_TYPE
                                 )
-
+        
         self.assertEqual( len( registry.listProfiles() ), 1 )
         self.assertEqual( len( registry.listProfileInfo() ), 1 )
 

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_stepzcml.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_stepzcml.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_stepzcml.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -44,13 +44,14 @@
 
     def testEmptyImport(self):
         zcml.load_string(EMPTY_ZCML)
-        self.assertEqual(_import_step_registry._registered, {})
+        self.assertEqual(len(_import_step_registry.listSteps()), 0)
 
     def testOneStepImport(self):
         zcml.load_string(ONE_STEP_ZCML)
-        self.assertEqual(_import_step_registry._registered.keys(),
+        self.assertEqual(_import_step_registry.listSteps(),
             [ u'Products.GenericSetup.teststep'  ])
-        info = _import_step_registry._registered[ u'Products.GenericSetup.teststep' ]
+        info = _import_step_registry.getStepMetadata(
+            u'Products.GenericSetup.teststep')
         self.assertEqual( info['description'],
                 u'step description' )
         self.assertEqual( info['title'],

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_tool.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_tool.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_tool.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -73,8 +73,6 @@
     _PROFILE_PATH2 = '/tmp/STT_test2'
 
     def afterSetUp(self):
-        self._profile_registry_info = profile_registry._profile_info
-        self._profile_registry_ids = profile_registry._profile_ids
         profile_registry.clear()
         global _before_import_events
         global _after_import_events
@@ -84,8 +82,6 @@
         provideHandler(handleProfileImportedEvent)
 
     def beforeTearDown(self):
-        profile_registry._profile_info = self._profile_registry_info
-        profile_registry._profile_ids = self._profile_registry_ids
         base_registry.unregisterHandler(handleBeforeProfileImportEvent)
         base_registry.unregisterHandler(handleProfileImportedEvent)
         FilesystemTestBase.beforeTearDown(self)
@@ -929,8 +925,6 @@
         path = os.path.join(directory, 'versioned_profile')
 
         # register profile
-        orig_profile_reg = (profile_registry._profile_info.copy(),
-                            profile_registry._profile_ids[:])
         profile_registry.registerProfile(profile_id,
                                          'Dummy Profile',
                                          'This is a dummy profile',
@@ -965,8 +959,7 @@
         _upgrade_registry._registry = orig_upgrade_registry
 
         # reset profile registry
-        (profile_registry._profile_info,
-         profile_registry._profile_ids) = orig_profile_reg
+        profile_registry.unregisterProfile(profile_id, product_name)
 
     def test_manage_doUpgrades_no_profile_id_or_updates(self):
         site = self._makeSite()
@@ -994,8 +987,9 @@
             tool.manage_doUpgrades()
             self.assertEqual(tool._profile_upgrade_versions, {})
         finally:
-            _upgrade_registry._registry.clear()
-            _upgrade_registry._registry.update(old)
+            _upgrade_registry.clear()
+            for key in old:
+                _upgrade_registry._registry[key] = old[key]
 
     def test_listExportSteps(self):
         site = self._makeSite()
@@ -1062,16 +1056,16 @@
         self.assertEqual(len(tool.listProfileInfo(for_=IAnotherSite)), 0)
 
 
-_DEFAULT_STEP_REGISTRIES_EXPORT_XML = """\
+_DEFAULT_STEP_REGISTRIES_EXPORT_XML = ("""\
 <?xml version="1.0"?>
 <export-steps>
  <export-step id="step_registries"
               handler="Products.GenericSetup.tool.exportStepRegistries"
               title="Export import / export steps.">
-  
+""" + "  " + """
  </export-step>
 </export-steps>
-"""
+""")
 
 _EXTRAS_STEP_REGISTRIES_EXPORT_XML = """\
 <?xml version="1.0"?>
@@ -1091,14 +1085,14 @@
 </export-steps>
 """
 
-_DEFAULT_STEP_REGISTRIES_IMPORT_XML = """\
+_DEFAULT_STEP_REGISTRIES_IMPORT_XML = ("""\
 <?xml version="1.0"?>
 <import-steps>
  <import-step id="foo" handler="foo.bar" title="foo">
-  
+""" + "  " + """
  </import-step>
 </import-steps>
-"""
+""")
 
 _EXTRAS_STEP_REGISTRIES_IMPORT_XML = """\
 <?xml version="1.0"?>

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_zcml.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_zcml.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/tests/test_zcml.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -61,9 +61,7 @@
 
       >>> from Products.GenericSetup.registry import _profile_registry
       >>> profile_id = 'Products.GenericSetup:default'
-      >>> profile_id in _profile_registry._profile_ids
-      True
-      >>> info = _profile_registry._profile_info[profile_id]
+      >>> info = _profile_registry.getProfileInfo(profile_id)
       >>> info['id']
       u'Products.GenericSetup:default'
       >>> info['title']
@@ -84,10 +82,6 @@
 
       >>> from zope.testing.cleanup import cleanUp
       >>> cleanUp()
-      >>> profile_id in _profile_registry._profile_ids
-      False
-      >>> profile_id in _profile_registry._profile_info
-      False
     """
 
 def test_registerProfile():
@@ -114,9 +108,7 @@
 
       >>> from Products.GenericSetup.registry import _profile_registry
       >>> profile_id = 'Products.GenericSetup:default'
-      >>> profile_id in _profile_registry._profile_ids
-      True
-      >>> info = _profile_registry._profile_info[profile_id]
+      >>> info = _profile_registry.getProfileInfo(profile_id)
       >>> info['id']
       u'Products.GenericSetup:default'
       >>> info['title']
@@ -137,10 +129,6 @@
 
       >>> from zope.testing.cleanup import cleanUp
       >>> cleanUp()
-      >>> profile_id in _profile_registry._profile_ids
-      False
-      >>> profile_id in _profile_registry._profile_info
-      False
     """
 
 def test_registerUpgradeStep(self):
@@ -263,7 +251,7 @@
       <function c_dummy_upgrade_handler at ...>
       >>> step2['title']
       u'Bar Upgrade Step 2'
-      
+
     First one listed should be second in the registry due to sortkey:
 
       >>> steps = profile_steps[1]
@@ -312,8 +300,6 @@
                                  handler="Products.GenericSetup.tests.test_zcml.dummy_importstep_handler">
                              </genericsetup:importStep>
                             </configure>""")
-        from Products.GenericSetup.zcml import _import_step_regs
-        self.assertEqual(_import_step_regs, [u'name'])
         self.assertEqual( _import_step_registry.listSteps(), [u'name'])
         data=_import_step_registry.getStepMetadata(u'name')
         self.assertEqual(data["handler"],
@@ -362,8 +348,6 @@
                                  />
                               </configure>
                               """)
-        from Products.GenericSetup.zcml import _export_step_regs
-        self.assertEqual(_export_step_regs, [u'name'])
         self.assertEqual( _export_step_registry.listSteps(), [u'name'])
         data=_export_step_registry.getStepMetadata(u'name')
         self.assertEqual(data["handler"],

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/upgrade.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/upgrade.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/upgrade.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -13,7 +13,8 @@
 
 from BTrees.OOBTree import OOBTree
 
-from registry import _profile_registry
+from Products.GenericSetup.interfaces import IUpgradeSteps
+from Products.GenericSetup.registry import GlobalRegistryStorage
 
 class UpgradeRegistry(object):
     """Registry of upgrade steps, by profile.
@@ -25,7 +26,7 @@
       - id -> [ (id1, step1), (id2, step2) ] for nested steps
     """
     def __init__(self):
-        self._registry = OOBTree()
+        self._registry = GlobalRegistryStorage(IUpgradeSteps)
 
     def __getitem__(self, key):
         return self._registry.get(key)
@@ -41,7 +42,7 @@
         None if there are no steps registered for a profile matching
         that id.
         """
-        profile_steps = self._registry.get(profile_id, None)
+        profile_steps = self._registry.get(profile_id)
         if profile_steps is None:
             self._registry[profile_id] = OOBTree()
             profile_steps = self._registry.get(profile_id)
@@ -51,7 +52,7 @@
         """Returns the specified upgrade step for the specified
         profile, or None if it doesn't exist.
         """
-        profile_steps = self._registry.get(profile_id, None)
+        profile_steps = self._registry.get(profile_id)
         if profile_steps is not None:
             step = profile_steps.get(step_id, None)
             if step is None:

Modified: Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/zcml.py
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/zcml.py	2011-03-29 15:22:29 UTC (rev 121156)
+++ Products.GenericSetup/branches/1.4-with-global-zca/Products/GenericSetup/zcml.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -70,7 +70,6 @@
         required=False)
 
 
-_profile_regs = []
 def registerProfile(_context, name=u'default', title=None, description=None,
                     directory=None, provides=BASE, for_=None):
     """ Add a new profile to the registry.
@@ -85,8 +84,6 @@
     if description is None:
         description = u''
 
-    _profile_regs.append('%s:%s' % (product, name))
-
     _context.action(
         discriminator = ('registerProfile', product, name),
         callable = _profile_registry.registerProfile,
@@ -118,11 +115,8 @@
         required=True)
 
 
-_export_step_regs = []
 
 def exportStep(context, name, handler, title=None, description=None):
-    global _export_step_regs
-    _export_step_regs.append(name)
 
     context.action(
         discriminator = ('exportStep', name),
@@ -163,8 +157,6 @@
         description=u'Name of another import step that has to be run first',
         required=True)
 
-_import_step_regs = []
-
 class importStep:
     def __init__(self, context, name, title, description, handler):
         """ Add a new import step to the registry.
@@ -183,8 +175,6 @@
 
 
     def __call__(self):
-        global _import_step_regs
-        _import_step_regs.append(self.name)
 
         self.context.action(
             discriminator = self.discriminator,
@@ -282,42 +272,3 @@
 
     def __call__(self):
         return ()
-
-
-#### cleanup
-
-def cleanUpProfiles():
-    global _profile_regs
-    for profile_id in _profile_regs:
-        del _profile_registry._profile_info[profile_id]
-        _profile_registry._profile_ids.remove(profile_id)
-    _profile_regs = []
-
-    _upgrade_registry.clear()
-
-
-def cleanUpImportSteps():
-    global _import_step_regs
-    for name in  _import_step_regs:
-        try:
-             _import_step_registry.unregisterStep( name )
-        except KeyError:
-            pass
-
-    _import_step_regs=[]
-
-def cleanUpExportSteps():
-    global _export_step_regs
-    for name in  _export_step_regs:
-        try:
-             _export_step_registry.unregisterStep( name )
-        except KeyError:
-            pass
-
-    _export_step_regs=[]
-
-from zope.testing.cleanup import addCleanUp
-addCleanUp(cleanUpProfiles)
-addCleanUp(cleanUpImportSteps)
-addCleanUp(cleanUpExportSteps)
-del addCleanUp

Copied: Products.GenericSetup/branches/1.4-with-global-zca/bootstrap.py (from rev 109828, Products.GenericSetup/trunk/bootstrap.py)
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/bootstrap.py	                        (rev 0)
+++ Products.GenericSetup/branches/1.4-with-global-zca/bootstrap.py	2011-03-29 15:51:57 UTC (rev 121157)
@@ -0,0 +1,121 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 105417 2009-11-01 15:15:20Z tarek $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+from optparse import OptionParser
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+# parsing arguments
+parser = OptionParser()
+parser.add_option("-v", "--version", dest="version",
+                          help="use a specific zc.buildout version")
+parser.add_option("-d", "--distribute",
+                   action="store_true", dest="distribute", default=False,
+                   help="Use Disribute rather than Setuptools.")
+
+parser.add_option("-c", None, action="store", dest="config_file",
+                   help=("Specify the path to the buildout configuration "
+                         "file to be used."))
+
+options, args = parser.parse_args()
+
+# if -c was provided, we push it back into args for buildout' main function
+if options.config_file is not None:
+    args += ['-c', options.config_file]
+
+if options.version is not None:
+    VERSION = '==%s' % options.version
+else:
+    VERSION = ''
+
+USE_DISTRIBUTE = options.distribute
+args = args + ['bootstrap']
+
+to_reload = False
+try:
+    import pkg_resources
+    if not hasattr(pkg_resources, '_distribute'):
+        to_reload = True
+        raise ImportError
+except ImportError:
+    ez = {}
+    if USE_DISTRIBUTE:
+        exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
+                         ).read() in ez
+        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
+    else:
+        exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                             ).read() in ez
+        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    if to_reload:
+        reload(pkg_resources)
+    else:
+        import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+
+if USE_DISTRIBUTE:
+    requirement = 'distribute'
+else:
+    requirement = 'setuptools'
+
+if is_jython:
+    import subprocess
+
+    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+           quote(tmpeggs), 'zc.buildout' + VERSION],
+           env=dict(os.environ,
+               PYTHONPATH=
+               ws.find(pkg_resources.Requirement.parse(requirement)).location
+               ),
+           ).wait() == 0
+
+else:
+    assert os.spawnle(
+        os.P_WAIT, sys.executable, quote (sys.executable),
+        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
+        dict(os.environ,
+            PYTHONPATH=
+            ws.find(pkg_resources.Requirement.parse(requirement)).location
+            ),
+        ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout' + VERSION)
+import zc.buildout.buildout
+zc.buildout.buildout.main(args)
+shutil.rmtree(tmpeggs)

Copied: Products.GenericSetup/branches/1.4-with-global-zca/buildout.cfg (from rev 109828, Products.GenericSetup/trunk/buildout.cfg)
===================================================================
--- Products.GenericSetup/branches/1.4-with-global-zca/buildout.cfg	                        (rev 0)
+++ Products.GenericSetup/branches/1.4-with-global-zca/buildout.cfg	2011-03-29 15:51:57 UTC (rev 121157)
@@ -0,0 +1,34 @@
+[buildout]
+extends = http://dist.plone.org/release/3.3.5/versions.cfg
+develop = .
+parts =
+    zope2
+    test
+    zopepy
+
+unzip = true
+
+versions=versions
+
+[versions]
+zc.recipe.testrunner = 1.2.0
+zope.testing = 3.9.5
+
+[zope2]
+recipe = plone.recipe.zope2install
+fake-zope-eggs = true
+skip-fake-eggs = zope.testing
+url = ${versions:zope2-url}
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = Products.GenericSetup
+extra-paths = ${zope2:location}/lib/python
+
+
+[zopepy]
+recipe = zc.recipe.egg
+eggs =
+    Products.GenericSetup
+interpreter = zopepy
+scripts = zopepy



More information about the checkins mailing list