Log message for revision 40754:
  Fixed OFS.ObjectManager list_import() to tolerate missing directories.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/OFS/ObjectManager.py
  U   Zope/trunk/lib/python/OFS/tests/testObjectManager.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt  2005-12-12 20:42:18 UTC (rev 40753)
+++ Zope/trunk/doc/CHANGES.txt  2005-12-12 20:55:46 UTC (rev 40754)
@@ -115,6 +115,9 @@
 
     Bugs Fixed
 
+      - OFS ObjectManager: Fixed list_imports() to tolerate missing
+        import directories.
+
       - Collector #1621, 1894:  Removed support for use of long-deprecated
         'whrandom' module.
 

Modified: Zope/trunk/lib/python/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/ObjectManager.py  2005-12-12 20:42:18 UTC (rev 
40753)
+++ Zope/trunk/lib/python/OFS/ObjectManager.py  2005-12-12 20:55:46 UTC (rev 
40754)
@@ -625,6 +625,8 @@
             paths.append(cfg.instancehome)
         for impath in paths:
             directory = os.path.join(impath, 'import')
+            if not os.path.isdir(directory):
+                continue
             listing += [f for f in os.listdir(directory)
                         if f.endswith('.zexp') or f.endswith('.xml')]
         return listing

Modified: Zope/trunk/lib/python/OFS/tests/testObjectManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testObjectManager.py        2005-12-12 
20:42:18 UTC (rev 40753)
+++ Zope/trunk/lib/python/OFS/tests/testObjectManager.py        2005-12-12 
20:55:46 UTC (rev 40754)
@@ -108,7 +108,6 @@
         self.assertEqual( si.__ac_local_roles__, None )
 
     def test_setObject_set_owner_with_emergency_user( self ):
-
         om = self._makeOne()
 
         newSecurityManager( None, emergency_user )
@@ -380,6 +379,16 @@
         self.assertRaises(BadRequest, om._setObject, 'REQUEST', si)
         self.assertRaises(BadRequest, om._setObject, '/', si)
 
+    def test_list_imports(self):
+        om = self._makeOne()
+        # This must work whether we've done "make instance" or not.
+        # So list_imports() may return an empty list, or whatever's
+        # in skel/import. Tolerate both cases.
+        self.failUnless(isinstance(om.list_imports(), list))
+        for filename in om.list_imports():
+            self.failUnless(filename.endswith('.zexp') or
+                            filename.endswith('.xml'))
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest( unittest.makeSuite( ObjectManagerTests ) )

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to