コード例 #1
0
ファイル: models.py プロジェクト: Web5design/openlibrary
 def get_lists(self, limit=1000, offset=0, sort=True):
     q = {"type": "/type/list", "seeds": self.get_seed(), "limit": limit, "offset": offset}
     keys = web.ctx.site.things(q)
     lists = web.ctx.site.get_many(keys)
     if sort:
         lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
     return lists
コード例 #2
0
    def get_lists(self, seed=None, limit=100, offset=0, sort=True):
        """Returns all the lists of this user.
        
        When seed is specified, this returns all the lists which contain the
        given seed.
        
        seed could be an object or a string like "subject:cheese".
        """
        q = {
            "type": "/type/list",
            "key~": self.key + "/lists/*",
            "limit": limit,
            "offset": offset
        }
        if seed:
            if isinstance(seed, Thing):
                seed = {"key": seed.key}
            q['seeds'] = seed

        keys = self._site.things(q)
        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists,
                               reverse=True,
                               key=lambda list: list.last_update)
        return lists
コード例 #3
0
ファイル: models.py プロジェクト: dmontalvo/openlibrary
 def _get_lists(self, limit=50, offset=0, sort=True):
     q = {"type": "/type/list", "seeds": {"key": self.key}, "limit": limit, "offset": offset}
     keys = self._site.things(q)
     lists = self._site.get_many(keys)
     if sort:
         lists = h.safesort(lists, reverse=True, key=lambda list: list.last_update)
     return lists
コード例 #4
0
    def _get_lists(self, limit=50, offset=0, sort=True):
        # cache the default case
        if limit == 50 and offset == 0:
            keys = self._get_lists_cached()
        else:
            keys = self._get_lists_uncached(limit=limit, offset=offset)

        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
        return lists
コード例 #5
0
ファイル: models.py プロジェクト: zgruza/openlibrary
    def _get_lists(self, limit=50, offset=0, sort=True):
        # cache the default case
        if limit == 50 and offset == 0:
            keys = self._get_lists_cached()
        else:
            keys = self._get_lists_uncached(limit=limit, offset=offset)

        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
        return lists
コード例 #6
0
ファイル: models.py プロジェクト: zgruza/openlibrary
 def get_lists(self, limit=1000, offset=0, sort=True):
     q = {
         "type": "/type/list",
         "seeds": self.get_seed(),
         "limit": limit,
         "offset": offset
     }
     keys = web.ctx.site.things(q)
     lists = web.ctx.site.get_many(keys)
     if sort:
         lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
     return lists
コード例 #7
0
 def _get_lists(self, limit=50, offset=0, sort=True):
     q = {
         "type": "/type/list",
         "seeds": {
             "key": self.key
         },
         "limit": limit,
         "offset": offset
     }
     keys = self._site.things(q)
     lists = self._site.get_many(keys)
     if sort:
         lists = h.safesort(lists,
                            reverse=True,
                            key=lambda list: list.last_update)
     return lists
コード例 #8
0
    def get_lists(self, seed=None, limit=100, offset=0, sort=True):
        """Returns all the lists of this user.

        When seed is specified, this returns all the lists which contain the
        given seed.

        seed could be an object or a string like "subject:cheese".
        """
        # cache the default case
        if seed is None and limit == 100 and offset == 0:
            keys = self._get_lists_cached()
        else:
            keys = self._get_lists_uncached(seed=seed, limit=limit, offset=offset)

        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
        return lists
コード例 #9
0
ファイル: models.py プロジェクト: zgruza/openlibrary
    def get_lists(self, seed=None, limit=100, offset=0, sort=True):
        """Returns all the lists of this user.

        When seed is specified, this returns all the lists which contain the
        given seed.

        seed could be an object or a string like "subject:cheese".
        """
        # cache the default case
        if seed is None and limit == 100 and offset == 0:
            keys = self._get_lists_cached()
        else:
            keys = self._get_lists_uncached(seed=seed, limit=limit, offset=offset)

        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists, reverse=True, key=lambda list: list.last_modified)
        return lists
コード例 #10
0
ファイル: models.py プロジェクト: dmontalvo/openlibrary
    def get_lists(self, seed=None, limit=100, offset=0, sort=True):
        """Returns all the lists of this user.
        
        When seed is specified, this returns all the lists which contain the
        given seed.
        
        seed could be an object or a string like "subject:cheese".
        """
        q = {"type": "/type/list", "key~": self.key + "/lists/*", "limit": limit, "offset": offset}
        if seed:
            if isinstance(seed, Thing):
                seed = {"key": seed.key}
            q["seeds"] = seed

        keys = self._site.things(q)
        lists = self._site.get_many(keys)
        if sort:
            lists = h.safesort(lists, reverse=True, key=lambda list: list.last_update)
        return lists