2009-05-13 16:54:06 +02:00
|
|
|
"""The default comment class and factory.
|
2009-05-11 18:52:16 +02:00
|
|
|
"""
|
|
|
|
|
2009-05-13 16:54:06 +02:00
|
|
|
from zope.interface import implements
|
|
|
|
from zope.component.factory import Factory
|
2009-05-11 18:52:16 +02:00
|
|
|
|
|
|
|
from Acquisition import Explicit
|
|
|
|
from OFS.Traversable import Traversable
|
|
|
|
from AccessControl.Role import RoleManager
|
|
|
|
from AccessControl.Owned import Owned
|
|
|
|
|
2009-05-13 16:54:06 +02:00
|
|
|
from plone.app.discussion.interfaces import IComment
|
2009-05-11 18:52:16 +02:00
|
|
|
|
|
|
|
class Comment(Explicit, Traversable, RoleManager, Owned):
|
|
|
|
"""A comment.
|
|
|
|
|
|
|
|
This object attempts to be as lightweight as possible. We implement a
|
|
|
|
number of standard methods instead of subclassing, to have total control
|
|
|
|
over what goes into the object.
|
|
|
|
"""
|
|
|
|
|
|
|
|
implements(IComment)
|
|
|
|
|
|
|
|
meta_type = portal_type = 'Discussion Item'
|
|
|
|
|
|
|
|
__parent__ = None
|
2009-05-13 17:20:02 +02:00
|
|
|
|
|
|
|
comment_id = None # int
|
2009-05-11 18:52:16 +02:00
|
|
|
|
|
|
|
title = u""
|
|
|
|
|
2009-05-13 16:54:06 +02:00
|
|
|
mime_type = "text/plain"
|
2009-05-11 18:52:16 +02:00
|
|
|
text = u""
|
|
|
|
|
|
|
|
creator = None
|
|
|
|
creation_date = None
|
|
|
|
modification_date = None
|
|
|
|
|
|
|
|
author_username = None
|
|
|
|
|
|
|
|
author_name = None
|
|
|
|
author_email = None
|
|
|
|
|
2009-05-13 17:20:02 +02:00
|
|
|
def __init__(self, id=0, conversation=None, **kw):
|
|
|
|
self.comment_id = id
|
2009-05-13 16:54:06 +02:00
|
|
|
self.__parent__ = conversation
|
2009-05-11 18:52:16 +02:00
|
|
|
|
|
|
|
for k, v in kw:
|
|
|
|
setattr(self, k, v)
|
2009-05-16 06:46:47 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def in_reply_to(self):
|
|
|
|
# TODO
|
|
|
|
return None
|
2009-05-11 18:52:16 +02:00
|
|
|
|
2009-05-13 17:20:02 +02:00
|
|
|
@property
|
|
|
|
def __name__(self):
|
|
|
|
return unicode(self.comment_id)
|
|
|
|
|
2009-05-11 18:52:16 +02:00
|
|
|
@property
|
|
|
|
def id(self):
|
2009-05-13 17:20:02 +02:00
|
|
|
return str(self.comment_id)
|
2009-05-11 18:52:16 +02:00
|
|
|
|
|
|
|
def getId(self):
|
2009-05-13 16:54:06 +02:00
|
|
|
"""The id of the comment, as a string
|
|
|
|
"""
|
|
|
|
return self.id
|
|
|
|
|
|
|
|
def Title(self):
|
|
|
|
"""The title of the comment
|
|
|
|
"""
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
def Creator(self):
|
|
|
|
"""The name of the person who wrote the comment
|
|
|
|
"""
|
|
|
|
return self.creator
|
|
|
|
|
|
|
|
CommentFactory = Factory(Comment)
|