[CMF-checkins] CVS: Products/CMFDefault - Favorite.py:1.24

Grégoire Weber zope.org at incept.ch
Thu Aug 5 11:39:59 EDT 2004


Update of /cvs-repository/Products/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv30178

Modified Files:
	Favorite.py 
Log Message:
- adding a unique id to the remote object of a favorite didn't work in the favorites '__init__' method as 'self' was not yet wrapped thus the uid tools were not found. The solution was to move that code to the manage_afterAdd hook. Unfortunately after this change 'test_MetadataCataloguing' in 'test_portal.py' failed because the favorite also cataloged the site root (which is correct) but the test assumed only the content type got catalgoed and thus failed. So the unit test had to be updated accordingly.


=== Products/CMFDefault/Favorite.py 1.23 => 1.24 ===
--- Products/CMFDefault/Favorite.py:1.23	Thu Jul 22 06:22:19 2004
+++ Products/CMFDefault/Favorite.py	Thu Aug  5 11:39:29 2004
@@ -68,6 +68,7 @@
     portal_obj = portal_url.getPortalObject()
     content_obj = portal_obj.restrictedTraverse( remote_url )
     relUrl = portal_url.getRelativeUrl( content_obj )
+    
     o=Favorite( id, title, relUrl, description )
     self._setObject(id,o)
 
@@ -95,8 +96,18 @@
         self.remote_url=remote_url
         self.description = description
         
+    def manage_afterAdd(self, item, container):
+        """Intercept after favorite has beeing added.
+        
+        The tools are not reachable in '__init__' because 'self' is 
+        not yet wrapped at this time. That's why the after add hook
+        has to be intercepted.
+        """
         # save unique id of favorite
         self.remote_uid = self._getUidByUrl()
+        
+        # do the usual stuff
+        Link.manage_afterAdd(self, item, container)
         
     def _getUidByUrl(self):
         """Registers and returns the uid of the remote object if



More information about the CMF-checkins mailing list