[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/
Fix relative paths for profile dependencies.
Ross Patterson
me at rpatterson.net
Sun Nov 25 04:42:42 EST 2007
Log message for revision 81983:
Fix relative paths for profile dependencies.
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/registry.py
A Products.GenericSetup/trunk/Products/GenericSetup/tests/metadata_profile/
A Products.GenericSetup/trunk/Products/GenericSetup/tests/metadata_profile/metadata.xml
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_profile_metadata.py
U Products.GenericSetup/trunk/Products/GenericSetup/tool.py
U Products.GenericSetup/trunk/Products/GenericSetup/utils.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2007-11-25 00:13:34 UTC (rev 81982)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2007-11-25 09:42:41 UTC (rev 81983)
@@ -2,6 +2,8 @@
GenericSetup 1.4 (unreleased)
+ - Fix relative paths for profile dependencies.
+
- Add support for context dependencies in profiles.
- Deprecate the version field for import steps.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/registry.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/registry.py 2007-11-25 00:13:34 UTC (rev 81982)
+++ Products.GenericSetup/trunk/Products/GenericSetup/registry.py 2007-11-25 09:42:41 UTC (rev 81983)
@@ -38,6 +38,7 @@
from utils import _resolveDottedName
from utils import _extractDocstring
from utils import _computeTopologicalSort
+from utils import _getProductPath
class BaseStepRegistry( Implicit ):
@@ -551,7 +552,8 @@
, 'for': for_
}
- metadata = ProfileMetadata( path )()
+ metadata = ProfileMetadata(
+ os.path.join(_getProductPath(product), path) )()
version = metadata.get( 'version', None )
if version is None and product is not None:
Added: Products.GenericSetup/trunk/Products/GenericSetup/tests/metadata_profile/metadata.xml
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/metadata_profile/metadata.xml (rev 0)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/metadata_profile/metadata.xml 2007-11-25 09:42:41 UTC (rev 81983)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<metadata>
+ <description>Description from metadata</description>
+</metadata>
\ No newline at end of file
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_profile_metadata.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_profile_metadata.py 2007-11-25 00:13:34 UTC (rev 81982)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_profile_metadata.py 2007-11-25 09:42:41 UTC (rev 81983)
@@ -69,6 +69,17 @@
product = getattr(self.app.Control_Panel.Products, product_name)
self.assertEqual(profile_info['version'], product.version)
+ def test_relativePath(self):
+ profile_id = 'dummy_profile2'
+ product_name = 'GenericSetup'
+ profile_registry.registerProfile(
+ profile_id, 'Dummy Profile', 'This is a dummy profile',
+ 'tests/metadata_profile', product=product_name)
+ profile_info = profile_registry.getProfileInfo(
+ '%s:%s' % (product_name, profile_id))
+ self.assertEqual(profile_info['description'],
+ 'Description from metadata')
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite( ProfileMetadataTests ),
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2007-11-25 00:13:34 UTC (rev 81982)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2007-11-25 09:42:41 UTC (rev 81983)
@@ -59,6 +59,7 @@
from utils import _resolveDottedName
from utils import _wwwdir
from utils import _computeTopologicalSort
+from utils import _getProductPath
IMPORT_STEPS_XML = 'import_steps.xml'
EXPORT_STEPS_XML = 'export_steps.xml'
@@ -936,25 +937,6 @@
#
# Helper methods
#
- security.declarePrivate('_getProductPath')
- def _getProductPath(self, product_name):
-
- """ Return the absolute path of the product's directory.
- """
- try:
- # BBB: for GenericSetup 1.1 style product names
- product = __import__('Products.%s' % product_name
- , globals(), {}, ['initialize'])
- except ImportError:
- try:
- product = __import__(product_name
- , globals(), {}, ['initialize'])
- except ImportError:
- raise ValueError('Not a valid product name: %s'
- % product_name)
-
- return product.__path__[0]
-
security.declarePrivate('_getImportContext')
def _getImportContext(self, context_id, should_purge=None, archive=None):
@@ -968,7 +950,7 @@
info = _profile_registry.getProfileInfo(context_id)
if info.get('product'):
- path = os.path.join(self._getProductPath(info['product'])
+ path = os.path.join(_getProductPath(info['product'])
, info['path'])
else:
path = info['path']
Modified: Products.GenericSetup/trunk/Products/GenericSetup/utils.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2007-11-25 00:13:34 UTC (rev 81982)
+++ Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2007-11-25 09:42:41 UTC (rev 81983)
@@ -826,3 +826,22 @@
unresolved = []
return result
+
+def _getProductPath(product_name):
+
+ """ Return the absolute path of the product's directory.
+ """
+ try:
+ # BBB: for GenericSetup 1.1 style product names
+ product = __import__('Products.%s' % product_name
+ , globals(), {}, ['initialize'])
+ except ImportError:
+ try:
+ product = __import__(product_name
+ , globals(), {}, ['initialize'])
+ except ImportError:
+ raise ValueError('Not a valid product name: %s'
+ % product_name)
+
+ return product.__path__[0]
+
More information about the Checkins
mailing list