Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFDefault.DiscussionItem.DiscussionItemContainer Class Reference
Inheritance diagram for CMFDefault.DiscussionItem.DiscussionItemContainer:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.DiscussionItem.DiscussionItemContainer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getId
def getReply
def __bobo_traverse__
def manage_afterAdd
def manage_afterClone
def manage_beforeDelete
def objectIds
def objectItems
def objectValues
def createReply
def deleteReply
def hasReplies
def replyCount
def getReplies
def quotedContents

Public Attributes

 id

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _repcount
def _getReplyParent
def _getDiscussable
def _getReplyResults

Private Attributes

 _container

Static Private Attributes

 __implements__ = z2IDiscussable

Detailed Description

    Store DiscussionItem objects. Discussable content that
    has DiscussionItems associated with it will have an
    instance of DiscussionItemContainer injected into it to
    hold the discussion threads.

Definition at line 154 of file DiscussionItem.py.


Constructor & Destructor Documentation

Definition at line 171 of file DiscussionItem.py.

00171 
00172     def __init__(self):
00173         self.id = 'talkback'
00174         self._container = PersistentMapping()


Member Function Documentation

This will make this container traversable

Definition at line 189 of file DiscussionItem.py.

00189 
00190     def __bobo_traverse__(self, REQUEST, name):
00191         """
00192         This will make this container traversable
00193         """
00194         target = getattr(self, name, None)
00195         if target is not None:
00196             return target
00197 
00198         else:
00199             try:
00200                 return self.getReply(name)
00201             except:
00202                 parent = aq_parent( aq_inner( self ) )
00203                 if parent.getId() == name:
00204                     return parent
00205                 else:
00206                     REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, ''))

Here is the call graph for this function:

def CMFDefault.DiscussionItem.DiscussionItemContainer._getDiscussable (   self,
  outer = 0 
) [private]

Definition at line 389 of file DiscussionItem.py.

00389 
00390     def _getDiscussable( self, outer=0 ):
00391         """
00392         """
00393         tb = outer and aq_inner( self ) or self
00394         return getattr( tb, 'aq_parent', None )

Here is the caller graph for this function:

def CMFDefault.DiscussionItem.DiscussionItemContainer._getReplyParent (   self,
  in_reply_to 
) [private]
    Return the object indicated by the 'in_reply_to', where
    'None' represents the "outer" content object.

Definition at line 377 of file DiscussionItem.py.

00377 
00378     def _getReplyParent( self, in_reply_to ):
00379         """
00380             Return the object indicated by the 'in_reply_to', where
00381             'None' represents the "outer" content object.
00382         """
00383         outer = self._getDiscussable( outer=1 )
00384         if in_reply_to is None:
00385             return outer
00386         parent = self._container[ in_reply_to ].__of__( aq_inner( self ) )
00387         return parent.__of__( outer )

Here is the call graph for this function:

   Get a list of ids of DiscussionItems which are replies to
   our Discussable.

Definition at line 396 of file DiscussionItem.py.

00396 
00397     def _getReplyResults( self ):
00398         """
00399            Get a list of ids of DiscussionItems which are replies to
00400            our Discussable.
00401         """
00402         discussable = self._getDiscussable()
00403         outer = self._getDiscussable( outer=1 )
00404 
00405         if discussable == outer:
00406             in_reply_to = None
00407         else:
00408             in_reply_to = discussable.getId()
00409 
00410         result = []
00411         a = result.append
00412         for key, value in self._container.items():
00413             if value.in_reply_to == in_reply_to:
00414                 a( ( key, value ) )
00415 
00416         result.sort( lambda a, b: cmp(a[1].creation_date, b[1].creation_date) )
00417 
00418         return [ x[0] for x in result ]
00419 
00420 InitializeClass(DiscussionItemContainer)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.DiscussionItem.DiscussionItemContainer._repcount (   self,
  replies 
) [private]
counts the total number of replies by recursing thru the various levels

Definition at line 335 of file DiscussionItem.py.

00335 
00336     def _repcount( self, replies ):
00337         """  counts the total number of replies by recursing thru the various levels
00338         """
00339         count = 0
00340 
00341         for reply in replies:
00342             count = count + 1
00343 
00344             #if there is at least one reply to this reply
00345             replies = reply.talkback.getReplies()
00346             if replies:
00347                 count = count + self._repcount( replies )
00348 
00349         return count

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.DiscussionItem.DiscussionItemContainer.createReply (   self,
  title,
  text,
  Creator = None,
  text_format = 'structured-text' 
)
    Create a reply in the proper place

Definition at line 272 of file DiscussionItem.py.

00272 
00273     def createReply( self, title, text, Creator=None, text_format='structured-text' ):
00274         """
00275             Create a reply in the proper place
00276         """
00277         container = self._container
00278 
00279         id = int(DateTime().timeTime())
00280         while self._container.get( str(id), None ) is not None:
00281             id = id + 1
00282         id = str( id )
00283 
00284         item = DiscussionItem( id, title=title, description=title )
00285         self._container[id] = item
00286         item = item.__of__(self)
00287 
00288         item.setFormat(text_format)
00289         item._edit(text)
00290         item.addCreator(Creator)
00291         item.indexObject()
00292 
00293         item.setReplyTo( self._getDiscussable() )
00294         item.notifyWorkflowCreated()
00295 
00296         return id

Here is the call graph for this function:

Remove a reply from this container 

Definition at line 298 of file DiscussionItem.py.

00298 
00299     def deleteReply( self, reply_id ):
00300         """ Remove a reply from this container """
00301         if self._container.has_key( reply_id ):
00302             reply = self._container.get( reply_id ).__of__( self )
00303             my_replies = reply.talkback.getReplies()
00304             for my_reply in my_replies:
00305                 my_reply_id = my_reply.getId()
00306                 self.deleteReply(my_reply_id)
00307 
00308             if hasattr( reply, 'unindexObject' ):
00309                 reply.unindexObject()
00310 
00311             del self._container[reply_id]
00312 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 176 of file DiscussionItem.py.

00176 
00177     def getId( self ):
00178         return self.id

Return a sequence of the IDiscussionResponse objects which are
    associated with this Discussable

Definition at line 351 of file DiscussionItem.py.

00351 
00352     def getReplies( self ):
00353         """ Return a sequence of the IDiscussionResponse objects which are
00354             associated with this Discussable
00355         """
00356         objects = []
00357         a = objects.append
00358         result_ids = self._getReplyResults()
00359 
00360         for id in result_ids:
00361             a( self._container.get( id ).__of__( self ) )
00362 
00363         return objects

Here is the call graph for this function:

    Return a discussion item, given its ID;  raise KeyError
    if not found.

Definition at line 180 of file DiscussionItem.py.

00180 
00181     def getReply( self, reply_id ):
00182         """
00183             Return a discussion item, given its ID;  raise KeyError
00184             if not found.
00185         """
00186         return self._container.get( reply_id ).__of__(self)

Here is the caller graph for this function:

    Test to see if there are any dicussion items

Definition at line 314 of file DiscussionItem.py.

00314 
00315     def hasReplies( self, content_obj ):
00316         """
00317             Test to see if there are any dicussion items
00318         """
00319         outer = self._getDiscussable( outer=1 )
00320         if content_obj == outer:
00321             return bool( len(self._container) )
00322         else:
00323             return bool( len( content_obj.talkback._getReplyResults() ) )

Here is the call graph for this function:

    We have juste been added or moved.
    Add the contained items to the catalog.

Definition at line 208 of file DiscussionItem.py.

00208 
00209     def manage_afterAdd(self, item, container):
00210         """
00211             We have juste been added or moved.
00212             Add the contained items to the catalog.
00213         """
00214         if aq_base(container) is not aq_base(self):
00215             for obj in self.objectValues():
00216                 obj.__of__(self).indexObject()

Here is the call graph for this function:

    We have just been cloned.
    Notify the workflow about the contained items.

Definition at line 218 of file DiscussionItem.py.

00218 
00219     def manage_afterClone(self, item):
00220         """
00221             We have just been cloned.
00222             Notify the workflow about the contained items.
00223         """
00224         for obj in self.objectValues():
00225             obj.__of__(self).notifyWorkflowCreated()

Here is the call graph for this function:

    Remove the contained items from the catalog.

Definition at line 227 of file DiscussionItem.py.

00227 
00228     def manage_beforeDelete(self, item, container):
00229         """
00230             Remove the contained items from the catalog.
00231         """
00232         if aq_base(container) is not aq_base(self):
00233             for obj in self.objectValues():
00234                 obj.__of__(self).unindexObject()

Here is the call graph for this function:

    Return a list of the ids of our DiscussionItems.

Definition at line 239 of file DiscussionItem.py.

00239 
00240     def objectIds( self, spec=None ):
00241         """
00242             Return a list of the ids of our DiscussionItems.
00243         """
00244         if spec and spec is not DiscussionItem.meta_type:
00245             return []
00246         return self._container.keys()
00247 

Here is the caller graph for this function:

    Return a list of (id, subobject) tuples for our DiscussionItems.

Definition at line 249 of file DiscussionItem.py.

00249 
00250     def objectItems(self, spec=None):
00251         """
00252             Return a list of (id, subobject) tuples for our DiscussionItems.
00253         """
00254         r=[]
00255         a=r.append
00256         g=self._container.get
00257         for id in self.objectIds(spec):
00258             a( (id, g( id ) ) )
00259         return r
00260 

Here is the call graph for this function:

Here is the caller graph for this function:

    Return a list of our DiscussionItems.

Definition at line 262 of file DiscussionItem.py.

00262 
00263     def objectValues(self):
00264         """
00265             Return a list of our DiscussionItems.
00266         """
00267         return self._container.values()

Here is the caller graph for this function:

    Return this object's contents in a form suitable for inclusion
    as a quote in a response.

Definition at line 365 of file DiscussionItem.py.

00365 
00366     def quotedContents(self):
00367         """
00368             Return this object's contents in a form suitable for inclusion
00369             as a quote in a response.
00370         """
00371 
00372         return ""

How many replies do i have? 

Definition at line 325 of file DiscussionItem.py.

00325 
00326     def replyCount( self, content_obj ):
00327         """ How many replies do i have? """
00328         outer = self._getDiscussable( outer=1 )
00329         if content_obj == outer:
00330             return len( self._container )
00331         else:
00332             replies = content_obj.talkback.getReplies()
00333             return self._repcount( replies )

Here is the call graph for this function:


Member Data Documentation

Definition at line 164 of file DiscussionItem.py.

Definition at line 173 of file DiscussionItem.py.

Definition at line 172 of file DiscussionItem.py.

tuple CMFDefault.DiscussionItem.DiscussionItemContainer.security = ClassSecurityInfo() [static]

Definition at line 169 of file DiscussionItem.py.


The documentation for this class was generated from the following file: