Ejemplo n.º 1
0
    def _list(self,
              project=None,
              kfilter={},
              marker=None,
              limit=storage.DEFAULT_TOPICS_PER_PAGE,
              detailed=False,
              name=None):

        query = utils.scoped_query(marker,
                                   project,
                                   name,
                                   kfilter,
                                   key_value='p_t')

        projection = {'p_t': 1, '_id': 0}
        if detailed:
            projection['m'] = 1

        cursor = self._collection.find(query, projection=projection)
        cursor = cursor.limit(limit).sort('p_t')
        marker_name = {}

        def normalizer(record):
            topic = {'name': utils.descope_queue_name(record['p_t'])}
            marker_name['next'] = topic['name']
            if detailed:
                topic['metadata'] = record['m']
            return topic

        yield utils.HookedCursor(cursor, normalizer)
        yield marker_name and marker_name['next']
Ejemplo n.º 2
0
    def _list(self,
              project=None,
              marker=None,
              limit=storage.DEFAULT_QUEUES_PER_PAGE,
              detailed=False):

        query = utils.scoped_query(marker, project)

        projection = {'p_q': 1, '_id': 0}
        if detailed:
            projection['m'] = 1

        cursor = self._collection.find(query, projection=projection)
        cursor = cursor.limit(limit).sort('p_q')
        marker_name = {}

        def normalizer(record):
            queue = {'name': utils.descope_queue_name(record['p_q'])}
            marker_name['next'] = queue['name']
            if detailed:
                queue['metadata'] = record['m']
            return queue

        yield utils.HookedCursor(cursor, normalizer)
        yield marker_name and marker_name['next']
Ejemplo n.º 3
0
Archivo: queues.py Proyecto: rose/zaqar
    def _list(self, project=None, marker=None,
              limit=storage.DEFAULT_QUEUES_PER_PAGE, detailed=False):

        query = utils.scoped_query(marker, project)

        fields = {'p_q': 1, '_id': 0}
        if detailed:
            fields['m'] = 1

        cursor = self._collection.find(query, fields=fields)
        cursor = cursor.limit(limit).sort('p_q')
        marker_name = {}

        def normalizer(record):
            queue = {'name': utils.descope_queue_name(record['p_q'])}
            marker_name['next'] = queue['name']
            if detailed:
                queue['metadata'] = record['m']
            return queue

        yield utils.HookedCursor(cursor, normalizer)
        yield marker_name and marker_name['next']
Ejemplo n.º 4
0
    def _list(self, project=None, kfilter={}, marker=None,
              limit=storage.DEFAULT_TOPICS_PER_PAGE, detailed=False,
              name=None):

        query = utils.scoped_query(marker, project, name, kfilter,
                                   key_value='p_t')

        projection = {'p_t': 1, '_id': 0}
        if detailed:
            projection['m'] = 1

        cursor = self._collection.find(query, projection=projection)
        cursor = cursor.limit(limit).sort('p_t')
        marker_name = {}

        def normalizer(record):
            topic = {'name': utils.descope_queue_name(record['p_t'])}
            marker_name['next'] = topic['name']
            if detailed:
                topic['metadata'] = record['m']
            return topic

        yield utils.HookedCursor(cursor, normalizer)
        yield marker_name and marker_name['next']
Ejemplo n.º 5
0
    def list(self, project):
        fields = {'_id': 0}

        query = utils.scoped_query(None, project)
        return utils.HookedCursor(self._col.find(query, fields), _normalize)
Ejemplo n.º 6
0
    def list(self, project):
        fields = {'_id': 0}

        query = utils.scoped_query(None, project)
        return utils.HookedCursor(self._col.find(query, fields),
                                  _normalize)
Ejemplo n.º 7
0
 def _calculate_resource_count(self, project=None):
     query = utils.scoped_query(None, project, None, {})
     projection = {'p_q': 1, '_id': 0}
     return self._collection.find(query, projection=projection).count()