[Zope3-checkins] SVN: Zope3/trunk/ - Fixed bug in TypeRegistry for

Christian Theune ct at gocept.com
Thu Jun 10 10:17:57 EDT 2004


Log message for revision 25331:
   - Fixed bug in TypeRegistry for
     zope.app.publisher.browser.globalbrowsermenuservice which allows
     passing classes instead of interfaces as well but has a missing import.



-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2004-06-10 14:07:45 UTC (rev 25330)
+++ Zope3/trunk/doc/CHANGES.txt	2004-06-10 14:17:57 UTC (rev 25331)
@@ -12,6 +12,13 @@
 
     Bug fixes
 
+      - Fixed bug in TypeRegistry for
+        zope.app.publisher.browser.globalbrowsermenuservice which allows
+        passing classes instead of interfaces as well but has a missing import.
+
+      - Assuming a "text/" content type for all files by default
+        broke the edit form. "" is the default by now.
+
       - A monkey patch to cope with weakref problems in Python 2.3.3
         was removed, so Python 2.3.4 is required now.
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py	2004-06-10 14:07:45 UTC (rev 25330)
+++ Zope3/trunk/src/zope/app/publisher/browser/globalbrowsermenuservice.py	2004-06-10 14:17:57 UTC (rev 25331)
@@ -19,7 +19,7 @@
 
 import sys
 from zope.exceptions import DuplicationError, Unauthorized, Forbidden
-from zope.interface import implements
+from zope.interface import implements, implementedBy
 from zope.security.checker import CheckerPublic
 from zope.security import checkPermission
 from zope.app.component.metaconfigure import handler
@@ -48,12 +48,12 @@
         self._reg = {}
 
     def register(self, interface, object):
-        if not (interface is None or IInterface.providedBy(interface)):
+        if interface is not None and not IInterface.providedBy(interface):
             if isinstance(interface, (type, types.ClassType)):
-                interface = zope.interface.implementedBy(interface)
+                interface = implementedBy(interface)
             else:
                 raise TypeError(
-                    "The interface argument must be an interface (or None)")
+                    "The interface argument must be an interface (or None) or a class.")
         
         self._reg[interface] = object
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py	2004-06-10 14:07:45 UTC (rev 25330)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py	2004-06-10 14:17:57 UTC (rev 25331)
@@ -36,6 +36,9 @@
 class I12(I1): pass
 class I111(I11): pass
 
+class C1(object):
+    implements(I1)
+            
 class TestObject:
     implements(IBrowserPublisher, I111)
 
@@ -227,7 +230,17 @@
                 ]
         self.assertEqual(menu, [d(5), d(6), d(7), d(8), d(3), d(2), d(1)])
 
+    def test_addWrong(self):
+        r = self.__reg()
+        
+        x = []
+        r.menu('test_id', 'test menu')
+        self.assertRaises(TypeError, r.menuItem, 'test_id', x, 'a1', 'a2',' a3')
 
+    def test_addClass(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        r.menuItem('test_id', C1, 'a1', 'a2', 'a3')
 
 def test_suite():
     return unittest.TestSuite((




More information about the Zope3-Checkins mailing list