# Path: cms/dbutil.py
# def get_mongodb(request):
# def get_collection(request, name):
# def get_gridfs(request, collection='fs'):
# def encode_keys(d):
# def get_es_conn(request):
# def get_es_index_name(request):
# def serve_gridfs_file(file):
# def serve_gridfs_file_for_id(request, id, collection='fs'):
# 
# Path: cms/exceptions.py
# class Veto(Exception):
#     """ May be raised when an attempt is made to do something that the CMS doesn't allow,
#     such as adding an object to a folder with a name that's already in use.
#     Higher level code (such as views) may want to catch these Veto exceptions
#     and present them to end users in a friendly manner.
#     """
#     def __init__(self, msg):
#         Exception.__init__(self, msg)


from cms import dbutil
from cms.exceptions import Veto
import string

class Collection(object):
    """ A flat collection (corresponds to a MongoDB collection) of similar Objects,
    each with a unique __name__ value.
    Collection instances are NOT stored as MongoDB documents.
    """

    _object_type = "collection"

    def __init__(self, request, collection_name, child_class):
        """
        collection_name - name of the MongoDB collection
        child_class - the class used to construct children of this collection
        """
        self.request = request
        self._collection_name = collection_name
        self._child_class = child_class

    def _get_collection(self):

# Path: cms/dbutil.py
# def get_mongodb(request):
# def get_collection(request, name):
# def get_gridfs(request, collection='fs'):
# def encode_keys(d):
# def get_es_conn(request):
# def get_es_index_name(request):
# def serve_gridfs_file(file):
# def serve_gridfs_file_for_id(request, id, collection='fs'):
# 
# Path: cms/exceptions.py
# class Veto(Exception):
#     """ May be raised when an attempt is made to do something that the CMS doesn't allow,
#     such as adding an object to a folder with a name that's already in use.
#     Higher level code (such as views) may want to catch these Veto exceptions
#     and present them to end users in a friendly manner.
#     """
#     def __init__(self, msg):
#         Exception.__init__(self, msg)


# Path: cms/resources/collection.py
from cms import dbutil
from cms.exceptions import Veto
import string


class Collection(object):
    """ A flat collection (corresponds to a MongoDB collection) of similar Objects,
    each with a unique __name__ value.
    Collection instances are NOT stored as MongoDB documents.
    """

    _object_type = "collection"

    def __init__(self, request, collection_name, child_class):
        """
        collection_name - name of the MongoDB collection
        child_class - the class used to construct children of this collection
        """
        self.request = request
        self._collection_name = collection_name
        self._child_class = child_class

    def _get_collection(self):

        return dbutil.get_collection(self.request, self._collection_name)