Ejemplo n.º 1
0
    def get(self):
        policies = getUtilitiesFor(IFavoritesPolicy)
        mtool = getToolByName(self.context, 'portal_membership')
        user_id = mtool.getAuthenticatedMember().getId()
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        site = getNavigationRootObject(self.context, portal)
        favorites_list = IFavoriteStorage(site).list_favorites(user_id)

        favorites_infos = []
        for policy_name, policy in policies:
            favorites_infos.extend(policy.get_favorites_infos(self.context,
                    [fav for fav in favorites_list if fav['type'] == policy_name]))

        favorites_infos.sort(key=lambda x: x['index'])
        return favorites_infos
Ejemplo n.º 2
0
 def _callFUT(self, *args, **kw):
     from zope.component._api import getUtilitiesFor
     return getUtilitiesFor(*args, **kw)
Ejemplo n.º 3
0
 def _callFUT(self, *args, **kw):
     from zope.component._api import getUtilitiesFor
     return getUtilitiesFor(*args, **kw)