1 ## Script (Python) "addtoFavorites"
2 ##title=Add item to favourites
5 #TODO : translate messages
6 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
7 #_ = MessageIDFactory('plinn')
8 _
= lambda x
: lambda : x
10 portal
= context
.portal_url
.getPortalObject()
11 ttool
= portal
.portal_types
12 homeFolder
= portal
.portal_membership
.getHomeFolder()
14 if not hasattr(homeFolder
, 'Favorites'):
15 ttool
.constructContent( 'Plinn Folder', homeFolder
, 'Favorites', title
=str(_('Favorites')) )
17 targetFolder
= getattr( homeFolder
, 'Favorites' )
18 new_id
='fav_' + str(int( context
.ZopeTime()))
19 myPath
=context
.portal_url
.getRelativeUrl(context
)
20 targetFolder
.invokeFactory( 'Favorite', id=new_id
, title
=context
.TitleOrId(), remote_url
=myPath
)
22 context
.setStatus(True, 'Favorite added.')
23 context
.setRedirect(context
, 'object/view', ajax
=ajax
)