Get a pymongo collection from a namespace.
438785
def get_collection(self, namespace):
        """"""
        database, coll = namespace.split(".", 1)
        return self.primary_client[database][coll]
998679
def get_collection_for_cls(self, cls):
        
        if cls not in self.classes:
            if issubclass(cls, Document) and cls not in self.classes and cls not in self.deprecated_classes:
                self.autoregister(cls)
            else:
                raise AttributeError("Unknown object type: %s" % cls.__name__)
        collection = self.classes[cls]['collection']
        return collection
320177
def get_collection(self, collection_id=None, nav="children", page=None):
        
        return self.call(
            "collections",
            {
                "id": collection_id,
                "nav": nav,
                "page": page
            },
            defaults={
                "id": None,
                "nav": "children",
                "page": 1
            }
        )
914444
def collection(cls, cid):
        
        url = urljoin(config.API_URL, 'collections/%s' % cid)
        return Collection(cls.query(url=url))
682028
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'collections' in _dict:
            args['collections'] = [
                Collection._from_dict(x) for x in (_dict.get('collections'))
            ]
        return cls(**args)
361364
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'documents' in _dict:
            args['documents'] = EnvironmentDocuments._from_dict(
                _dict.get('documents'))
        if 'disk_usage' in _dict:
            args['disk_usage'] = DiskUsage._from_dict(_dict.get('disk_usage'))
        if 'collections' in _dict:
            args['collections'] = CollectionUsage._from_dict(
                _dict.get('collections'))
        return cls(**args)
572196
def find_all(self, collection):
        
        obj = getattr(self.db, collection)
        result = obj.find()
        return result
177460
def get_collections(kwdb, libtype="*"):
    """"""
    collections = kwdb.get_collections(libtype=libtype)
    for result in collections:
        url = flask.url_for(".doc_for_library", collection_id=result["collection_id"])
        result["url"] = url

    return collections
666374
def _collection(self, key):
    ''''''
    collection = str(key.path)
    if not collection in self._items:
      self._items[collection] = dict()
    return self._items[collection]
102287
def collection_names
      namespaces = self["system.namespaces"].find(name: { "$not" => /#{name}\.system\.|\$/ })
      namespaces.map do |doc|
        _name = doc["name"]
        _name[name.length + 1, _name.length]
      end
    end
873247
def collections(self):
        """"""
        # if cache server is configured, load collection from there
        if self.cache:
            return self.cache.get(
                self.app.config['COLLECTIONS_CACHE_KEY'])
1108709
def get_all(self):
        """"""
        logger.debug('Fetching items. Table: {namespace}'.format(
            namespace=self.namespace
        ))

        rows = []

        result = self.table.scan()

        while True:
            next_token = result.get('LastEvaluatedKey', None)
            rows += result['Items']

            if next_token:
                result = self.table.scan(ExclusiveStartKey=next_token)
            else:
                break

        return rows
597340
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'collection_id' in _dict:
            args['collection_id'] = _dict.get('collection_id')
        if 'name' in _dict:
            args['name'] = _dict.get('name')
        if 'description' in _dict:
            args['description'] = _dict.get('description')
        if 'created' in _dict:
            args['created'] = string_to_datetime(_dict.get('created'))
        if 'updated' in _dict:
            args['updated'] = string_to_datetime(_dict.get('updated'))
        if 'status' in _dict:
            args['status'] = _dict.get('status')
        if 'configuration_id' in _dict:
            args['configuration_id'] = _dict.get('configuration_id')
        if 'language' in _dict:
            args['language'] = _dict.get('language')
        if 'document_counts' in _dict:
            args['document_counts'] = DocumentCounts._from_dict(
                _dict.get('document_counts'))
        if 'disk_usage' in _dict:
            args['disk_usage'] = CollectionDiskUsage._from_dict(
                _dict.get('disk_usage'))
        if 'training_status' in _dict:
            args['training_status'] = TrainingStatus._from_dict(
                _dict.get('training_status'))
        if 'source_crawl' in _dict:
            args['source_crawl'] = SourceStatus._from_dict(
                _dict.get('source_crawl'))
        return cls(**args)
1109096
def collection_names(self, callback):
        """"""
        callback = partial(self._collection_names_result, callback)
        self["system.namespaces"].find(_must_use_master=True, callback=callback)
199246
def get(self):
        """"""
        namespaces = db.ConfigNamespace.order_by(
            ConfigNamespace.sort_order,
            ConfigNamespace.name
        ).all()

        return self.make_response({
            'message': None,
            'namespaces': namespaces
        }, HTTP.OK)
1341448
def get_collections(self):
        
        collections = self.request.matchdict['collections'].split('/')[0]
        collections = [coll.strip() for coll in collections.split(',')]
        return set(collections)
868190
def get_streams(self, namespace=None):
    
    request_dict = {}
    namespace = namespace or self.namespace
    if namespace is not None:
      request_dict['namespace'] = namespace
    response = self._make_request(self._streams_url,
                                  data=request_dict,
                                  stream=True)
    for line in response.iter_lines():
      if line:
        yield line