[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/tool.py Protect more places against profile_id being None

Wichert Akkerman wichert at wiggy.net
Wed Feb 20 10:10:17 EST 2008


Log message for revision 84079:
  Protect more places against profile_id being None

Changed:
  U   Products.GenericSetup/trunk/Products/GenericSetup/tool.py

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tool.py	2008-02-20 15:03:21 UTC (rev 84078)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tool.py	2008-02-20 15:10:17 UTC (rev 84079)
@@ -388,7 +388,10 @@
                                                  profile_id=profile_id,
                                                  archive=archive,
                                                  ignore_dependencies=ignore_dependencies)
-        prefix = 'import-all-%s' % profile_id.replace(':', '_')
+        if profile_id is None:
+            prefix = 'import-all-from-tar'
+        else:
+            prefix = 'import-all-%s' % profile_id.replace(':', '_')
         name = self._mangleTimestampName(prefix, 'log')
         self._createReport(name, result['steps'], result['messages'])
 
@@ -984,26 +987,26 @@
         """
         encoding = self.getEncoding()
 
-        if context_id.startswith('profile-'):
+        if context_id is not None:
+            if context_id.startswith('profile-'):
+                context_id = context_id[len('profile-'):]
+                info = _profile_registry.getProfileInfo(context_id)
 
-            context_id = context_id[len('profile-'):]
-            info = _profile_registry.getProfileInfo(context_id)
+                if info.get('product'):
+                    path = os.path.join(_getProductPath(info['product'])
+                                       , info['path'])
+                else:
+                    path = info['path']
+                if should_purge is None:
+                    should_purge = (info.get('type') != EXTENSION)
+                return DirectoryImportContext(self, path, should_purge, encoding)
 
-            if info.get('product'):
-                path = os.path.join(_getProductPath(info['product'])
-                                   , info['path'])
-            else:
-                path = info['path']
-            if should_purge is None:
-                should_purge = (info.get('type') != EXTENSION)
-            return DirectoryImportContext(self, path, should_purge, encoding)
-
-        elif context_id.startswith('snapshot-'):
-            context_id = context_id[len('snapshot-'):]
-            if should_purge is None:
-                should_purge = True
-            return SnapshotImportContext(self, context_id, should_purge, encoding)
-        elif context_id is None and archive is not None:
+            elif context_id.startswith('snapshot-'):
+                context_id = context_id[len('snapshot-'):]
+                if should_purge is None:
+                    should_purge = True
+                return SnapshotImportContext(self, context_id, should_purge, encoding)
+        elif archive is not None:
             return TarballImportContext(tool=self,
                                        archive_bits=archive,
                                        encoding='UTF8',
@@ -1147,7 +1150,7 @@
                                    ignore_dependencies=False,
                                    seen=None):
 
-        if profile_id is not None or not ignore_dependencies:
+        if profile_id is not None and not ignore_dependencies:
             try: 
                 chain = self.getProfileDependencyChain( profile_id )
             except KeyError, e:



More information about the Checkins mailing list