Ejemplo n.º 1
0
    def _delObject(self, id, dp=1, suppress_events=False):
        """Delete an object from this container.

        Also sends IObjectWillBeRemovedEvent and IObjectRemovedEvent.
        """
        ob = self._getOb(id)

        OFS.subscribers.compatibilityCall('manage_beforeDelete', ob, ob, self)

        if not suppress_events:
            notify(ObjectWillBeRemovedEvent(ob, self, id))

        self._objects = tuple([i for i in self._objects if i['id'] != id])
        self._delOb(id)

        # Indicate to the object that it has been deleted. This is
        # necessary for object DB mount points. Note that we have to
        # tolerate failure here because the object being deleted could
        # be a Broken object, and it is not possible to set attributes
        # on Broken objects.
        try:
            ob._v__object_deleted__ = 1
        except:
            pass

        if not suppress_events:
            notify(ObjectRemovedEvent(ob, self, id))
            notifyContainerModified(self)
Ejemplo n.º 2
0
 def _delObject(self, id):
     object = self._getOb(id)
     notify(ObjectWillBeRemovedEvent(object, self, id))
     if hasattr(aq_base(object), 'manage_beforeDelete'):
         object.manage_beforeDelete(object, self)
     self._delOb(id)
     notify(ObjectRemovedEvent(object, self, id))
     notifyContainerModified(self)
Ejemplo n.º 3
0
 def delete(self, id):
     # We need to fire an ObjectRemovedEvent ourselves here because
     # self[id].__parent__ is not exactly the same as self, which
     # in the end means that __delitem__ does not fire an
     # ObjectRemovedEvent for us.
     #
     # Also, now we can say the oldParent is the issue instead of
     # this adapter.
     event = ObjectRemovedEvent(self[id], oldParent=self.context,
                                oldName=id)
     self.remove(self[id])
     notify(event)
Ejemplo n.º 4
0
    def _delObject(self, id, dp=1, suppress_events=False):
        ob = self._getOb(id)

        OFS.subscribers.compatibilityCall('manage_beforeDelete', ob, ob, self)

        if not suppress_events:
            notify(ObjectWillBeRemovedEvent(ob, self, id))

        self._delOb(id)

        if not suppress_events:
            notify(ObjectRemovedEvent(ob, self, id))
            notifyContainerModified(self)
Ejemplo n.º 5
0
    def deleteDocument(self,doc):
        """delete the document from database
        """
        if not self.isCurrentUserAuthor(doc):
            raise Unauthorized, "You cannot delete this document."
        else:
            # execute the onDeleteDocument code of the form
            form = doc.getForm()
            if form:
                try:
                    self.runFormulaScript("form_"+form.id+"_ondelete", doc, form.onDeleteDocument)
                except PlominoScriptException, e:
                    e.reportError('Document has been deleted, but onDelete event failed.')

            self.getIndex().unindexDocument(doc)
            if self.getIndexInPortal():
                self.portal_catalog.uncatalog_object("/".join(self.getPhysicalPath() + (doc.id,)))
            event.notify(ObjectRemovedEvent(doc, self.documents, doc.id))
            self.documents._delOb(doc.id)