def manage_pasteObjects(self, cp):
     """ merge another conversation """
     try:
         op, mdatas = _cb_decode(cp)
     except Exception:
         raise CopyError("Invalid content")
     if op == 0:
         raise ValueError('Not allowed to copy content into conversation')
     if op != 1:
         raise ValueError("Invalid operation of content")
     obj = self.unrestrictedTraverse(mdatas[0])
     if IConversation.providedBy(obj):
         if obj.getParentNode() != self.getParentNode():
             raise ValueError("Invalid parent of content")
         forum = obj.getForum()
         obj_id = obj.getId()
         o_list = obj.objectValues()
         oblist = [Moniker(o1).dump() for o1 in o_list]
         cp = (1, oblist)
         cp = _cb_encode(cp)
         CopyContainer.manage_pasteObjects(self, cp)
         forum.manage_delObjects([obj_id])
     elif IComment.providedBy(obj):
         return CopyContainer.manage_pasteObjects(self, cp)
     else:
         raise ValueError('Invalid type of content')
Exemple #2
0
    def manage_renameObject(self, id=None, new_id=None, REQUEST=None):
        """manage renaming an object while keeping coherency for contained
      and linked to objects inside the renamed object

      """
        ob = self._getOb(id)
        # Make sure there is no activities pending on that object
        try:
            portal_activities = self.getPortalObject().portal_activities
        except AttributeError:
            pass  # There is no activity tool
        else:
            if portal_activities.countMessage(path=ob.getPath()) > 0:
                raise ActivityPendingError, 'Sorry, pending activities prevent ' \
                               +  'changing id at this current stage'

        # Search for categories that have to be updated in sub objects.
        self._recursiveSetActivityAfterTag(ob)
        self._updateInternalRelatedContent(
            object=ob,
            path_item_list=ob.getRelativeUrl().split("/"),
            new_id=new_id)
        #ob._v_is_renamed = 1
        # Rename the object
        return OriginalCopyContainer.manage_renameObject(self,
                                                         id=id,
                                                         new_id=new_id,
                                                         REQUEST=REQUEST)
Exemple #3
0
  def manage_copyObjects(self, ids=None, uids=None, REQUEST=None, RESPONSE=None):
      """
        Put a reference to the objects named in ids in the clip board
      """
      #LOG("Manage Copy",0, "ids:%s uids:%s" % (str(ids), str(uids)))
      if ids is not None:
        # Use default methode
        return OriginalCopyContainer.manage_copyObjects(self, ids, REQUEST,
            RESPONSE)
      if uids is None and REQUEST is not None:
          return eNoItemsSpecified
      elif uids is None:
          raise ValueError, 'uids must be specified'

      if isinstance(uids, (str, int)):
          ids=[uids]
      oblist=[]
      for uid in uids:
          ob=self.getPortalObject().portal_catalog.getObject(uid)
          if not ob.cb_isCopyable():
              raise CopyError, eNotSupported % uid
          m=Moniker.Moniker(ob)
          oblist.append(m.dump())
      cp=(0, oblist)
      cp=_cb_encode(cp)
      if REQUEST is not None:
          resp=REQUEST['RESPONSE']
          resp.setCookie('__cp', cp, path='%s' % cookie_path(REQUEST))
          REQUEST['__cp'] = cp
          return self.manage_main(self, REQUEST)
      return cp
Exemple #4
0
    def manage_cutObjects(self,
                          ids=None,
                          uids=None,
                          REQUEST=None,
                          RESPONSE=None):
        """ manage cutting objects, ie objects will be copied ans deleted

      """
        #LOG("Manage Copy",0, "ids:%s uids:%s" % (str(ids), str(uids)))
        if ids is not None:
            # Use default methode
            return OriginalCopyContainer.manage_cutObjects(self, ids, REQUEST)
        if uids is None and REQUEST is not None:
            return eNoItemsSpecified
        elif uids is None:
            raise ValueError('uids must be specified')

        if isinstance(uids, (str, int)):
            ids = [uids]
        oblist = []
        for uid in uids:
            ob = self.getPortalObject().portal_catalog.getObject(uid)
            if not ob.cb_isMoveable():
                raise CopyError(eNotSupported % id)
            m = Moniker.Moniker(ob)
            oblist.append(m.dump())
        cp = (1, oblist)  # 0->1 This is the difference with manage_copyObject
        cp = _cb_encode(cp)
        if REQUEST is not None:
            resp = REQUEST['RESPONSE']
            resp.setCookie('__cp', cp, path='%s' % cookie_path(REQUEST))
            REQUEST['__cp'] = cp
            return self.manage_main(self, REQUEST)
        return cp
Exemple #5
0
  def manage_copyObjects(self, ids=None, uids=None, REQUEST=None, RESPONSE=None):
      """
        Put a reference to the objects named in ids in the clip board
      """
      #LOG("Manage Copy",0, "ids:%s uids:%s" % (str(ids), str(uids)))
      if ids is not None:
        # Use default methode
        return OriginalCopyContainer.manage_copyObjects(self, ids, REQUEST,
            RESPONSE)
      if uids is None and REQUEST is not None:
          return eNoItemsSpecified
      elif uids is None:
          raise ValueError, 'uids must be specified'

      if isinstance(uids, (str, int)):
          ids=[uids]
      oblist=[]
      for uid in uids:
          ob=self.getPortalObject().portal_catalog.getObject(uid)
          if not ob.cb_isCopyable():
              raise CopyError, eNotSupported % uid
          m=Moniker.Moniker(ob)
          oblist.append(m.dump())
      cp=(0, oblist)
      cp=_cb_encode(cp)
      if REQUEST is not None:
          resp=REQUEST['RESPONSE']
          resp.setCookie('__cp', cp, path='%s' % cookie_path(REQUEST))
          REQUEST['__cp'] = cp
          return self.manage_main(self, REQUEST)
      return cp
Exemple #6
0
def OS_manage_renameObject(self, id, new_id, REQUEST=None):
    """ Rename a particular sub-object without changing its position.
    """
    old_position = self.getObjectPosition(id)
    res = CopyContainer.manage_renameObject(self, id, new_id, REQUEST)
    try:
        self.moveObjectToPosition(new_id, old_position, suppress_events=True)
    except TypeError:
        # BBB: removed in Zope 2.11
        self.moveObjectToPosition(new_id, old_position)
        warnings.warn(
            "%s.moveObjectToPosition without suppress_events is "
            "deprecated and will be removed in Zope 2.11." %
            self.__class__.__name__, DeprecationWarning)
    return res
Exemple #7
0
def OS_manage_renameObject(self, id, new_id, REQUEST=None):
    """ Rename a particular sub-object without changing its position.
    """
    old_position = self.getObjectPosition(id)
    res = CopyContainer.manage_renameObject(self, id, new_id, REQUEST)
    try:
        self.moveObjectToPosition(new_id, old_position, suppress_events=True)
    except TypeError:
        # BBB: removed in Zope 2.11
        self.moveObjectToPosition(new_id, old_position)
        warnings.warn(
            "%s.moveObjectToPosition without suppress_events is "
            "deprecated and will be removed in Zope 2.11." %
            self.__class__.__name__, DeprecationWarning)
    return res
Exemple #8
0
  def manage_renameObject(self, id=None, new_id=None, REQUEST=None):
      """manage renaming an object while keeping coherency for contained
      and linked to objects inside the renamed object

      """
      ob = self._getOb(id)
      # Make sure there is no activities pending on that object
      try:
        portal_activities = self.getPortalObject().portal_activities
      except AttributeError:
        pass # There is no activity tool
      else:
        if portal_activities.countMessage(path=ob.getPath())>0:
          raise ActivityPendingError, 'Sorry, pending activities prevent ' \
                         +  'changing id at this current stage'

      # Search for categories that have to be updated in sub objects.
      self._recursiveSetActivityAfterTag(ob)
      self._updateInternalRelatedContent(object=ob,
                                         path_item_list=ob.getRelativeUrl().split("/"),
                                         new_id=new_id)
      #ob._v_is_renamed = 1
      # Rename the object
      return OriginalCopyContainer.manage_renameObject(self, id=id, new_id=new_id, REQUEST=REQUEST)
 def _verifyObjectPaste(self, object, validate_src=1):
     # Objects in this container have an incorrect __factory_meta_type__.
     # Use the implementation that uses meta_type instead.
     return CopyContainer._verifyObjectPaste(self,
                                             object,
                                             validate_src=validate_src)
 def manage_pasteObjects(self, cp):
     """ move another conversation """
     CopyContainer.manage_pasteObjects(self, cp)
 def manage_pasteObjects(self, cp):
     """ move another conversation """
     CopyContainer.manage_pasteObjects(self, cp)
 def _verifyObjectPaste(self, object, validate_src=1):
     # Objects in this container have an incorrect __factory_meta_type__.
     # Use the implementation that uses meta_type instead.
     return CopyContainer._verifyObjectPaste(self, object,
         validate_src=validate_src)