Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Mikel

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

portada items

// description of your code here

    def getPortadaItems(self):
        """ Return a dict, with the latest 4 news and one new from
        each town. All news are muttualy excluyent. Included the one
        selected in the first slot of the page
            {'front-news':[n1,n2,n3,4],
             'town-news':[(town1_id, n5), (town2_id, n6), ...),]
        """
        
        context = self.context[0]
        front_new = None
        try:
            front_new = context.cp_container.slots['first'].objectValues()
            if front_new:
                front_new = front_new[0].dereference()
            else:
                front_new = None
        except IndexError:
            front_new = None
        except AttributeError:
            front_new = None

        ret_dict = {}
        ret_dict['front-news'] = self.getFrontNews(front_new)
        ret_dict['town-news'] = self.getTownNews(front_new, ret_dict['front-news'])

        return ret_dict

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS