[CMF-checkins] SVN: CMF/branches/2.1/C - fixed interface used for uid handler lookup

Yvo Schubbe y.2007- at wcm-solutions.de
Sun Mar 11 09:43:20 EDT 2007


Log message for revision 73139:
  - fixed interface used for uid handler lookup
  - removed unconditional CMFUid dependency
  - modernized related tests

Changed:
  U   CMF/branches/2.1/CHANGES.txt
  U   CMF/branches/2.1/CMFDefault/Favorite.py
  U   CMF/branches/2.1/CMFDefault/tests/test_Portal.py

-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt	2007-03-11 12:44:09 UTC (rev 73138)
+++ CMF/branches/2.1/CHANGES.txt	2007-03-11 13:43:19 UTC (rev 73139)
@@ -2,9 +2,13 @@
 
   Bug Fixes
 
-    - CMFActionIcons: Fixed interface declarations.
+    - Favorite: Fixed UID handling broken in 2.1.0-beta.
 
+    - CMFDefault: Removed CMFUid dependency inadvertently added in 2.1.0-beta.
 
+    - CMFActionIcons: Fixed interface declarations added in 2.1.0-beta.
+
+
 CMF 2.1.0-beta (2007/03/09)
 
   IMPORTANT NOTE:

Modified: CMF/branches/2.1/CMFDefault/Favorite.py
===================================================================
--- CMF/branches/2.1/CMFDefault/Favorite.py	2007-03-11 12:44:09 UTC (rev 73138)
+++ CMF/branches/2.1/CMFDefault/Favorite.py	2007-03-11 13:43:19 UTC (rev 73139)
@@ -17,10 +17,9 @@
 
 import urlparse
 
-from Globals import InitializeClass
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
-
+from Globals import InitializeClass
 from zope.app.container.interfaces import IObjectAddedEvent
 from zope.component import adapter
 from zope.component import getUtility
@@ -30,7 +29,10 @@
 
 from Products.CMFCore.interfaces import ISiteRoot
 from Products.CMFCore.interfaces import IURLTool
-from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
+try:
+    from Products.CMFUid.interfaces import IUniqueIdHandler
+except ImportError:
+    IUniqueIdHandler = None
 
 from DublinCore import DefaultDublinCoreImpl
 from interfaces import IFavorite
@@ -73,8 +75,8 @@
         the unique id handler tool is available.
         """
         # check for unique id handler tool
-        handler = queryUtility(IUniqueIdAnnotationManagement)
-        if handler is None or not hasattr(handler, 'register'):
+        handler = IUniqueIdHandler and queryUtility(IUniqueIdHandler)
+        if handler is None:
             return
 
         obj = getUtility(ISiteRoot).restrictedTraverse(self.remote_url)
@@ -85,15 +87,15 @@
         the unique id handler tool is available.
         """
         # check for unique id handler tool
-        handler = queryUtility(IUniqueIdAnnotationManagement)
-        if handler is None or not hasattr(handler, 'queryObject'):
+        handler = IUniqueIdHandler and queryUtility(IUniqueIdHandler)
+        if handler is None:
             return
-        
+
         # check for remote uid info on object
         uid = getattr(aq_base(self), 'remote_uid', None)
         if uid is None:
             return
-        
+
         return handler.queryObject(uid, None)
 
     security.declareProtected(View, 'getRemoteUrl')
@@ -110,7 +112,7 @@
             if url != remote_url:
                 self.edit(url)
             return url
-        
+
         return remote_url
 
     def _getRemoteUrlTheOldWay(self):

Modified: CMF/branches/2.1/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_Portal.py	2007-03-11 12:44:09 UTC (rev 73138)
+++ CMF/branches/2.1/CMFDefault/tests/test_Portal.py	2007-03-11 13:43:19 UTC (rev 73139)
@@ -22,8 +22,16 @@
 from AccessControl.User import UnrestrictedUser
 from Acquisition import aq_base
 from zope.app.component.hooks import setSite
+from zope.component import getUtility
+from zope.component import queryUtility
 
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import ITypesTool
 from Products.CMFDefault.testing import FunctionalLayer
+try:
+    from Products.CMFUid.interfaces import IUniqueIdHandler
+except ImportError:
+    IUniqueIdHandler = None
 
 
 class CMFSiteTests(ZopeTestCase.FunctionalTestCase):
@@ -45,17 +53,17 @@
         setSite(self.app.site)
 
     def test_new( self ):
-        site = self.app.site
+        catalog = getUtility(ICatalogTool)
 
-        self.assertEqual( len( site.portal_catalog ), 0 )
+        self.assertEqual(len(catalog), 0)
 
     def test_MetadataCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
-        site.portal_membership.memberareaCreationFlag = 0
-        uid_handler = getattr(site, 'portal_uidhandler', None)
+        catalog = getUtility(ICatalogTool)
+        ttool = getUtility(ITypesTool)
+        uid_handler = IUniqueIdHandler and queryUtility(IUniqueIdHandler)
 
-        portal_types = [ x for x in site.portal_types.listContentTypes()
+        portal_types = [ x for x in ttool.listContentTypes()
                            if x not in ( 'Discussion Item'
                                        , 'CMF BTree Folder'
                                        , 'Folder'
@@ -100,7 +108,7 @@
 
     def test_DocumentEditCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
+        catalog = getUtility(ICatalogTool)
 
         doc = self._makeContent( site
                                , portal_type='Document'
@@ -118,7 +126,7 @@
 
     def test_ImageEditCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
+        catalog = getUtility(ICatalogTool)
 
         doc = self._makeContent( site
                                , portal_type='Image'
@@ -134,7 +142,7 @@
 
     def test_FileEditCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
+        catalog = getUtility(ICatalogTool)
 
         doc = self._makeContent( site
                                , portal_type='File'
@@ -150,7 +158,7 @@
 
     def test_LinkEditCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
+        catalog = getUtility(ICatalogTool)
 
         doc = self._makeContent( site
                                , portal_type='Link'
@@ -166,7 +174,7 @@
 
     def test_NewsItemEditCataloguing( self ):
         site = self.app.site
-        catalog = site.portal_catalog
+        catalog = getUtility(ICatalogTool)
 
         doc = self._makeContent( site
                                , portal_type='News Item'



More information about the CMF-checkins mailing list