Remove "Plone 3 only" code; Do not monkey patch the BAD_TYPES vocabulary or plone.app.vocabularies anymore.

svn path=/plone.app.discussion/trunk/; revision=47311
This commit is contained in:
Timo Stollenwerk 2011-02-08 09:28:51 +00:00
parent 533fefa396
commit bf96d0082f
9 changed files with 46 additions and 157 deletions

View File

@ -1,6 +1,17 @@
Changelog
=========
2.0a1 (unreleased)
------------------
- Remove "Plone 3 only" code.
[timo]
- Do not monkey patch the BAD_TYPES vocabulary or plone.app.vocabularies
anymore.
[timo]
2.0a1 (2011-02-07)
------------------

View File

@ -2,15 +2,3 @@
from zope.i18nmessageid import MessageFactory
PloneAppDiscussionMessageFactory = MessageFactory('plone.app.discussion')
# Monkey patch plone.app.vocabularies.types.BAD_TYPES and remove
# 'Discussion Item' from this tuple, so that Comments can be found
# in the search. This will become needless once plone.app.discussion
# will become a part of Plone 4.
import plone.app.vocabularies.types
new_bad_types = list(plone.app.vocabularies.types.BAD_TYPES)
if 'Discussion Item' in new_bad_types:
new_bad_types.remove('Discussion Item')
plone.app.vocabularies.types.BAD_TYPES = new_bad_types

View File

@ -4,21 +4,6 @@
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone.app.discussion">
<!--
Plone 3 fixes
Plone 3 / Zope 2.10 does not recognize the meta:provides feature.
Therefore we claim to provide this feature when a suitable package is
installed.
-->
<configure zcml:condition="installed plone.formwidget.captcha">
<meta:provides feature="plone.app.discussion-captcha" />
</configure>
<configure zcml:condition="installed plone.formwidget.recaptcha">
<meta:provides feature="plone.app.discussion-captcha" />
</configure>
<!-- Captcha comment form extender -->
<configure zcml:condition="have plone.app.discussion-captcha">
<!--

View File

@ -11,26 +11,6 @@ from Products.statusmessages.interfaces import IStatusMessage
from plone.app.discussion.interfaces import _
from plone.app.discussion.interfaces import IComment
# Begin ugly hack. It works around a ContentProviderLookupError:
# plone.htmlhead error caused by Zope 2 permissions.
# This error occured on Plone 3.3.x only!
#
# Source:
# http://athenageek.wordpress.com/2008/01/08/
# contentproviderlookuperror-plonehtmlhead/
#
# Bug report: https://bugs.launchpad.net/zope2/+bug/176566
#
def _getContext(self): # pragma: no cover
self = self.aq_parent
while getattr(self, '_is_wrapperish', None):
self = self.aq_parent
return self
ZopeTwoPageTemplateFile._getContext = _getContext # pragma: no cover
# End ugly hack.
class View(BrowserView):
"""Main moderation View.

View File

@ -38,19 +38,9 @@ from plone.app.discussion.interfaces import IComment
from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IDiscussionSettings
try:
# Plone 4:
# Mixin CatalogAware and WorkflowAware into the Comment class
# is necessary for comments to be indexed in Plone4.
from Products.CMFCore.CMFCatalogAware import CatalogAware # pylint: disable-msg=W0611
from Products.CMFCore.CMFCatalogAware import WorkflowAware # pylint: disable-msg=W0611
PLONE_4 = True
except: # pragma: no cover
# Plone 3:
# Dummy imports to make Comment class happy
from OFS.Traversable import Traversable as CatalogAware # pylint: disable-msg=W0611
from OFS.Traversable import Traversable as WorkflowAware # pylint: disable-msg=W0611
PLONE_4 = False
from Products.CMFCore.CMFCatalogAware import CatalogAware
from Products.CMFCore.CMFCatalogAware import WorkflowAware
COMMENT_TITLE = _(u"comment_title",
default=u"${creator} on ${content}")
@ -240,7 +230,6 @@ def notify_user(obj, event):
context=obj.REQUEST)
for email in emails:
# Send email
if PLONE_4:
try:
mail_host.send(message,
email,
@ -252,18 +241,6 @@ def notify_user(obj, event):
'email from %s to %s',
sender,
email)
else: # pragma: no cover
try:
mail_host.secureSend(message,
email,
sender,
subject=subject,
charset='utf-8')
except SMTPException:
logger.error('SMTP exception while trying to send an ' +
'email from %s to %s',
sender,
email)
def notify_moderator(obj, event):
@ -307,7 +284,6 @@ def notify_moderator(obj, event):
context=obj.REQUEST)
# Send email
if PLONE_4:
try:
mail_host.send(message, mto, sender, subject, charset='utf-8')
except SMTPException, e:
@ -318,18 +294,3 @@ def notify_moderator(obj, event):
sender,
mto,
message)
else: # pragma: no cover
try:
mail_host.secureSend(message,
mto,
sender,
subject=subject,
charset='utf-8')
except SMTPException, e:
logger.error('SMTP exception (%s) while trying to send an ' +
'email notification to the comment moderator ' +
'(from %s to %s, message: %s)',
e,
sender,
mto,
message)

View File

@ -40,24 +40,13 @@ from zope.container.contained import ContainerModifiedEvent
from zope.lifecycleevent import ObjectCreatedEvent
try:
# Plone 4
from zope.lifecycleevent import ObjectAddedEvent
from zope.lifecycleevent import ObjectRemovedEvent
except ImportError: # pragma: no cover
# Plone 3.x
from zope.app.container.contained import ObjectAddedEvent # pragma: no cover
from zope.app.container.contained import ObjectRemovedEvent # pragma: no cover
from BTrees.OIBTree import OIBTree
try:
# These exist in new versions, but not in the one that comes with Zope 2.10.
from BTrees.LOBTree import LOBTree
from BTrees.LLBTree import LLSet
except ImportError: # pragma: no cover
from BTrees.OOBTree import OOBTree as LOBTree # pragma: no cover
from BTrees.OOBTree import OOSet as LLSet # pragma: no cover
from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IDiscussionSettings

View File

@ -71,14 +71,6 @@ class CommentTest(PloneTestCase):
conversation.addComment(comment1)
comment_brain = self.catalog.searchResults(
portal_type = 'Discussion Item')[0]
# comment should only have a UID if plone.uuid is present
try:
from plone.uuid.interfaces import IUUID
IUUID # pyflakes
except ImportError:
self.failIf(comment_brain.UID)
else:
self.failUnless(comment_brain.UID)
def test_uid_is_unique(self):
@ -89,10 +81,6 @@ class CommentTest(PloneTestCase):
conversation.addComment(comment2)
brains = self.catalog.searchResults(
portal_type = 'Discussion Item')
# make sure uids are either both None (i.e. without plone.uuid),
# or not equal
if brains[0].UID != None or brains[1].UID != None:
self.assertNotEquals(brains[0].UID, brains[1].UID)
def test_comment_uid_differs_from_content_uid(self):

View File

@ -680,14 +680,8 @@ class ConversationTest(PloneTestCase):
self.assertEquals(('', 'plone', 'doc1', '++conversation++default'),
conversation.getPhysicalPath())
# XXX: conversation.absolute_url() returns different values dependent
# on the Plone version used.
# Plone 3.3:
#self.assertEquals('plone/doc1/%2B%2Bconversation%2B%2Bdefault',
#conversation.absolute_url())
# Plone 4:
#self.assertEquals('http://nohost/plone/doc1/++conversation++default',
#conversation.absolute_url())
self.assertEquals('http://nohost/plone/doc1/++conversation++default',
conversation.absolute_url())
def test_parent(self):
# Check that conversation has a content object as parent
@ -701,7 +695,6 @@ class ConversationTest(PloneTestCase):
self.assertEquals(conversation.__parent__.getId(), 'doc1')
def test_discussion_item_not_in_bad_types(self):
self.failIf('Discussion Item' in BAD_TYPES)

View File

@ -214,12 +214,6 @@ class TestModeratorNotificationUnit(PloneTestCase):
self.failUnless(self.mailhost.messages[0])
msg = self.mailhost.messages[0]
if not isinstance(msg, str):
# Plone 3
self.failUnless('portal@plone.test' in msg.mfrom)
self.failUnless('portal@plone.test' in msg.mto)
else:
#Plone 4
self.failUnless('To: portal@plone.test' in msg)
self.failUnless('From: portal@plone.test' in msg)