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')
 def getConversation(self):
     """Returns containing conversation."""
     # Try containment
     stoptypes = ['Plone Site']
     for obj in aq_chain(aq_inner(self)):
         if hasattr(obj, 'portal_type') and obj.portal_type not in stoptypes:
             if IConversation.providedBy(obj):
                 return obj
     return None
 def getConversation(self):
     """Returns containing conversation."""
     # Try containment
     stoptypes = ['Plone Site']
     for obj in aq_chain(aq_inner(self)):
         if hasattr(obj, 'portal_type') and obj.portal_type not in stoptypes:
             if IConversation.providedBy(obj):
                 return obj
     return None
def publish_script(self, sci):
    """Publish the conversation along with comment"""
    object = sci.object

    wftool = sci.getPortal().portal_workflow

    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent,'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'publish')
            except Exception:
                pass
def autopublish_script(self, sci):
    """Publish the conversation along with the comment"""
    object = sci.object

    wftool = sci.getPortal().portal_workflow

    # Try to make sure that conversation and contained messages are in sync
    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent,'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'publish')
            except:
                pass
예제 #6
0
def autopublish_script(self, sci):
    """Publish the conversation along with the comment"""
    object = sci.object

    wftool = sci.getPortal().portal_workflow

    # Try to make sure that conversation and contained messages are in sync
    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent, 'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'publish')
            except ConflictError:
                raise
            except Exception:
                pass
def reject_script(self, sci):
    """Reject conversation along with comment"""
    # Dispatch to more easily customizable methods
    object = sci.object
    # We don't have notifyPublished method anymore
    #object.notifyRetracted()

    wftool = sci.getPortal().portal_workflow

    # Try to make sure that conversation and contained messages are in sync
    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                 if wftool.getInfoFor(parent,'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'reject')
            except Exception:
                pass
def publish_script(self, sci):
    """Publish the conversation along with comment"""
    object = sci.object

    wftool = sci.getPortal().portal_workflow

    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent,'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'publish')
            except ConflictError:
                raise
            except Exception:
                pass
            #Reindex conversation to update num_comments index
            parent.reindexObject(idxs=('num_comments',))
예제 #9
0
def publish_script(self, sci):
    """Publish the conversation along with comment"""
    object = sci.object

    wftool = sci.getPortal().portal_workflow

    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent, 'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'publish')
            except ConflictError:
                raise
            except Exception:
                pass
            # Reindex conversation to update num_comments index
            parent.reindexObject(idxs=('num_comments',))
예제 #10
0
def reject_script(self, sci):
    """Reject conversation along with comment"""
    # Dispatch to more easily customizable methods
    object = sci.object
    # We don't have notifyPublished method anymore
    # object.notifyRetracted()

    wftool = sci.getPortal().portal_workflow

    # Try to make sure that conversation and contained messages are in sync
    if IComment.providedBy(object):
        parent = aq_parent(aq_inner(object))
        if IConversation.providedBy(parent):
            try:
                if wftool.getInfoFor(parent, 'review_state', None) in (sci.old_state.getId(), 'pending'):
                    wftool.doActionFor(parent, 'reject')
            except ConflictError:
                raise
            except Exception:
                pass
예제 #11
0
 def testInterfaceConformance(self):
     self.failUnless(IConversation.providedBy(self.conv))
     self.failUnless(verifyObject(IConversation, self.conv))
 def testInterfaceConformance(self):
     self.failUnless(IConversation.providedBy(self.conv))
     self.failUnless(verifyObject(IConversation, self.conv))
예제 #13
0
파일: catalog.py 프로젝트: dtgit/dtedu
def num_comments(object, portal, **kw):
    conv = IConversation(object, None)
    if conv is None:
        return None
    else:
        return conv.getNumberOfComments()