Back to index

plone3  3.1.7
addtoFavorites.py
Go to the documentation of this file.
00001 ##parameters=
00002 ##
00003 from Products.CMFCore.utils import getToolByName
00004 
00005 mtool = getToolByName(script, 'portal_membership')
00006 
00007 home = mtool.getHomeFolder()
00008 if not hasattr(home, 'Favorites'):
00009     home.manage_addPortalFolder(id='Favorites', title='Favorites')
00010 favorites = getattr(home, 'Favorites')
00011 
00012 f_id = 'fav_' + str( int( context.ZopeTime() ) )
00013 f_title = context.TitleOrId()
00014 f_url = context.absolute_url()
00015 favorites.invokeFactory('Favorite', id=f_id, title=f_title, remote_url=f_url)
00016 
00017 context.setRedirect(context, 'object/view')