[Zope-CMF] Initial checkin of CMFUid (unique ids) and example usage diff for CMFDefault.Favorite

Gregoire Weber gregweb at gmx.ch
Wed Jul 21 00:40:17 EDT 2004


Hello All!

Unique ids have landed at the CMF HEAD. Have a look.


new unique id implementation
----------------------------

   http://cvs.zope.org/CMF/CMFUid/


Example Usage (Favorite)
------------------------

As an example of the usage of unique ids I'd like to add unique id support
to CMFDefaults Favorite content type. Favorites now follow the linked content 
item when it gets moved around in the portal.

The proposed Favorite implementation works with or without CMFUid installed
thus is fully backwards compatible.

Just checkout CMFUid, apply the diffs, restart Zope and add a new CMF instance.

Tres: Shall I add the enhancement to the favorites?

Gregoire


-------------------------------------------------------------------------------
gregweb at platon ~/data/Zope/inst/cmf_dev/Products/CMFDefault
$ cvs diff
cvs server: Diffing .
Index: Favorite.py
===================================================================
RCS file: /cvs-repository/Products/CMFDefault/Favorite.py,v
retrieving revision 1.22
diff -r1.22 Favorite.py
21a22
> from Acquisition import aq_base
95a97,121
>
>         # save unique id of favorite
>         self.remote_uid = self._getUidByUrl()
>
>     def _getUidByUrl(self):
>         handler = getToolByName(self, 'portal_uidhandler', None)
>         if handler is None or not hasattr(handler, 'queryObject'):
>             return
>
>         portal = getToolByName(self, 'portal_url').getPortalObject()
>         obj = portal.restrictedTraverse(self.remote_url)
>         return handler.register(obj)
>
>     def _getObjectByUid(self):
>         # give up if there is no uid handler
>         handler = getToolByName(self, 'portal_uidhandler', None)
>         if handler is None or not hasattr(handler, 'queryObject'):
>             return
>
>         # give up if remote uid information is not available
>         uid = getattr(aq_base(self), 'remote_uid', None)
>         if uid is None:
>             return
>
>         return handler.queryObject(uid, None)
101a128,135
>         # try getting the remote by unique id
>         remote_obj = self._getObjectByUid()
>         if remote_obj:
>             # update the url before returning it
>             url = remote_obj.absolute_url()
>             self._edit(url)
>             return url
>
124a159,162
>         remote_obj = self._getObjectByUid()
>         if remote_obj is not None:
>             return remote_obj
>
148a187,189
>
>         # save unique id of favorite
>         self.remote_uid = self._getUidByUrl()
Index: Portal.py
===================================================================
RCS file: /cvs-repository/Products/CMFDefault/Portal.py,v
retrieving revision 1.41
diff -r1.41 Portal.py
205c205,214
<
---
>
>         # try to install CMFUid without raising exceptions if not available
>         try:
>             addCMFUidTool = p.manage_addProduct['CMFUid'].manage_addTool
>         except AttributeError:
>             pass
>         else:
>             addCMFUidTool('Unique Id Generator Tool', None)
>             addCMFUidTool('Unique Id Handler Tool', None)
>
cvs server: Diffing Extensions
cvs server: Diffing dtml
cvs server: Diffing help
cvs server: Diffing images
cvs server: Diffing interfaces
cvs server: Diffing scripts
cvs server: Diffing skins
cvs server: Diffing skins/Images
cvs server: Diffing skins/content
cvs server: Diffing skins/control
cvs server: Diffing skins/generic
cvs server: Diffing skins/no_css
cvs server: Diffing skins/nouvelle
cvs server: Diffing skins/zpt_content
cvs server: Diffing skins/zpt_control
cvs server: Diffing skins/zpt_generic
cvs server: Diffing tests



More information about the Zope-CMF mailing list