Example #1
0
    def test7(self):
        def myCmp(s1, s2):
            return -cmp(s1, s2)

        md = {"myCmp" : myCmp}
        assert res7==ssort.sort(wordlist,
                                (("weight",), ("key", "myCmp", "desc")),
                                md,
                                mapping=1
                                )
Example #2
0
File: rss.py Project: goschtl/zope
 def items(self):
     """Return items according to policy"""
     syndtool = getUtility(ISyndicationTool)
     key, reverse = self.context.getDefaultSorting()
     items = syndtool.getSyndicatableContent(self.context)
     items = sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'),))
     items = LazyFilter(items, skip='View')
     items = ({'title': o.Title(), 'description': o.Description(),
               'creators': o.listCreators(), 'subjects': o.Subject(),
               'rights': o.Rights, 'publisher': o.Publisher(),
               'url': o.absolute_url(), 'date': o.modified().rfc822(),
               'uid': None}
               for idx, o in enumerate(items)
                 if idx < self.synd_info['max_items'])
     return items
Example #3
0
 def _get_items(self):
     key, reverse = self.context.getDefaultSorting()
     items = self.context.contentValues()
     items = sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'),))
     return LazyFilter(items, skip='View')
Example #4
0
 def _get_items(self):
     key, reverse = self._get_sorting()
     items = self.context.contentValues()
     return sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'),))
Example #5
0
 def _callFUT(self, *args, **kw):
     from zope.sequencesort.ssort import sort
     return sort(*args, **kw)
Example #6
0
 def _get_items(self):
     key, reverse = self._get_sorting()
     items = self.context.contentValues()
     return sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'), ))
Example #7
0
 def _get_items(self):
     (key, reverse) = self.context.getDefaultSorting()
     items = self.mtool().getRoster()
     items = sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'),))
     return LazyFilter(items, skip='View')
Example #8
0
 def _callFUT(self, *args, **kw):
     from zope.sequencesort.ssort import sort
     return sort(*args, **kw)
Example #9
0
 def test6(self):
     assert res6==ssort.sort(wordlist,
                             (("weight",),
                              ("key", "nocase", "desc")),
                             mapping=1)
Example #10
0
 def test5(self):
     assert res5==ssort.sort(wordlist, (("weight",), ("key",)),
                             mapping=1)
Example #11
0
 def test4(self):
     assert res4==ssort.sort(wordlist, (("key", "cmp", "desc"),),
                             mapping=1)
Example #12
0
 def test3(self):
     assert res3==ssort.sort(wordlist, (("key", "cmp"),), mapping=1)
Example #13
0
 def test2(self):
     assert res2==ssort.sort(wordlist, (("key",),), mapping=1)
Example #14
0
 def test1(self):
     assert res1==ssort.sort(wordlist)