# Path: cms/dateutil.py
# def utcnow(zero_seconds=False):
#     """ Returns a timezone aware version of utcnow.
#     If zero_seconds, the datetime will be rounded down to the minute.
#     """
#     now = datetime.datetime.now(pytz.utc)
#     if zero_seconds: return now.replace(second=0, microsecond=0)
#     return now
# 
# 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 folder import unindex_recursively
from collection import Collection
from interfaces import ITrash
from bson.objectid import ObjectId
from pyramid.security import authenticated_userid
from cms.dateutil import utcnow
from cms.exceptions import Veto
import zope.interface
import permissions
            trashed_by = authenticated_userid(self.request),
        )
        obj.__parent__ = self
        obj.__name__ = str(obj._id)
        obj.save()  # FIXME: set_modified=False?
        unindex_recursively(obj, include_self=True)
        # Notify old parent that child was moved (gives ordered folders an opportunity to update their ordered name list).
        orig_parent._child_removed(orig_name)
    
    def _child_removed(self, name):
        pass # Like I care?  I'm trash!

    def dememento_child(self, child):
        child.__name__ = child._memento['orig_name']
        del child._memento

    def veto_restore_child(self, child):
        """ Return an error message string if there's any reason why the given child cannot 
        be restored into its original parent.
        Otherwise return None.
        """
        root = self.__parent__
        orig_parent = root.get_content_by_id(child._memento['orig_parent_id'])
        if orig_parent is None: return "Original parent object no longer exists."
        if orig_parent.in_trash(): return "Original parent is also in the trash."
        return orig_parent.veto_add_child(child._memento['orig_name'], child)

    def restore_child(self, child):
        root = self.__parent__
        orig_parent = root.get_content_by_id(child._memento['orig_parent_id'])

# Path: cms/dateutil.py
# def utcnow(zero_seconds=False):
#     """ Returns a timezone aware version of utcnow.
#     If zero_seconds, the datetime will be rounded down to the minute.
#     """
#     now = datetime.datetime.now(pytz.utc)
#     if zero_seconds: return now.replace(second=0, microsecond=0)
#     return now
# 
# 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/trash.py
from folder import unindex_recursively
from collection import Collection
from interfaces import ITrash
from bson.objectid import ObjectId
from pyramid.security import authenticated_userid
from cms.dateutil import utcnow
from cms.exceptions import Veto
import zope.interface
import permissions

            trashed_by = authenticated_userid(self.request),
        )
        obj.__parent__ = self
        obj.__name__ = str(obj._id)
        obj.save()  # FIXME: set_modified=False?
        unindex_recursively(obj, include_self=True)
        # Notify old parent that child was moved (gives ordered folders an opportunity to update their ordered name list).
        orig_parent._child_removed(orig_name)
    
    def _child_removed(self, name):
        pass # Like I care?  I'm trash!

    def dememento_child(self, child):
        child.__name__ = child._memento['orig_name']
        del child._memento

    def veto_restore_child(self, child):
        """ Return an error message string if there's any reason why the given child cannot 
        be restored into its original parent.
        Otherwise return None.
        """
        root = self.__parent__
        orig_parent = root.get_content_by_id(child._memento['orig_parent_id'])
        if orig_parent is None: return "Original parent object no longer exists."
        if orig_parent.in_trash(): return "Original parent is also in the trash."
        return orig_parent.veto_add_child(child._memento['orig_name'], child)

    def restore_child(self, child):
        root = self.__parent__
        orig_parent = root.get_content_by_id(child._memento['orig_parent_id'])

        if orig_parent.in_trash(): raise Veto("Original parent is also in the trash.")