# 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
            if ch not in self.ALLOWED_NAME_CHARACTERS:
                return "The character \"%s\" is not allowed in names." % ch
        if unique and self.has_child(name): return "The name \"%s\" is already in use." % name
        return None

    def add_child(self, name, child):
        error = self.veto_add_child(name, child)
        if error: raise Veto(error)
        child.__name__ = name
        child.__parent__ = self
        child.save()

    def veto_add_child(self, name, child, unique=True):
        # Return an error message (string) if there's any reason why the specified child can't be added with the specified name.
        # Otherwise return None
        return self.veto_child_name(name, unique)

    def delete_child(self, name):
        child = self.get_child(name)
        if child:
            child._pre_delete()
            self._get_collection().remove(dict(_id=child._id), safe=True)
            return 1
        else:
            return 0

    def rename_child(self, name, newname, _validate=True):
        if name == newname: return 0
        if _validate:
            error = self.veto_child_name(newname)

# 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

            if ch not in self.ALLOWED_NAME_CHARACTERS:
                return "The character \"%s\" is not allowed in names." % ch
        if unique and self.has_child(name): return "The name \"%s\" is already in use." % name
        return None

    def add_child(self, name, child):
        error = self.veto_add_child(name, child)
        if error: raise Veto(error)
        child.__name__ = name
        child.__parent__ = self
        child.save()

    def veto_add_child(self, name, child, unique=True):
        # Return an error message (string) if there's any reason why the specified child can't be added with the specified name.
        # Otherwise return None
        return self.veto_child_name(name, unique)

    def delete_child(self, name):
        child = self.get_child(name)
        if child:
            child._pre_delete()
            self._get_collection().remove(dict(_id=child._id), safe=True)
            return 1
        else:
            return 0

    def rename_child(self, name, newname, _validate=True):
        if name == newname: return 0
        if _validate:
            error = self.veto_child_name(newname)

            if error: raise Veto(error)