Remove ImportError exceptions for Plone < 4.1 code and plone.z3cform < 0.6.0.

svn path=/plone.app.discussion/trunk/; revision=49033
This commit is contained in:
Timo Stollenwerk 2011-04-22 14:59:59 +00:00
parent 31ecf38129
commit b84211ddf0
4 changed files with 23 additions and 47 deletions

View File

@ -41,12 +41,8 @@ from plone.z3cform import z2
from plone.z3cform.widget import SingleCheckBoxWidget from plone.z3cform.widget import SingleCheckBoxWidget
from plone.z3cform.fieldsets import extensible from plone.z3cform.fieldsets import extensible
# starting from 0.6.0 version plone.z3cform has IWrappedForm interface
try: from plone.z3cform.interfaces import IWrappedForm
from plone.z3cform.interfaces import IWrappedForm
HAS_WRAPPED_FORM = True
except ImportError: # pragma: no cover
HAS_WRAPPED_FORM = False
COMMENT_DESCRIPTION_PLAIN_TEXT = _( COMMENT_DESCRIPTION_PLAIN_TEXT = _(
u"comment_description_plain_text", u"comment_description_plain_text",
@ -265,7 +261,6 @@ class CommentsViewlet(ViewletBase):
super(CommentsViewlet, self).update() super(CommentsViewlet, self).update()
z2.switch_on(self, request_layer=IFormLayer) z2.switch_on(self, request_layer=IFormLayer)
self.form = self.form(aq_inner(self.context), self.request) self.form = self.form(aq_inner(self.context), self.request)
if HAS_WRAPPED_FORM:
alsoProvides(self.form, IWrappedForm) alsoProvides(self.form, IWrappedForm)
self.form.update() self.form.update()

View File

@ -16,10 +16,8 @@ from plone.app.discussion.interfaces import IConversation, IComment
from plone.indexer import indexer from plone.indexer import indexer
try: from plone.uuid.interfaces import IUUID
from plone.uuid.interfaces import IUUID
except ImportError:
IUUID = None
MAX_DESCRIPTION = 25 MAX_DESCRIPTION = 25

View File

@ -40,11 +40,7 @@ from plone.app.discussion.interfaces import IDiscussionSettings
from Products.CMFCore.CMFCatalogAware import CatalogAware from Products.CMFCore.CMFCatalogAware import CatalogAware
from Products.CMFCore.CMFCatalogAware import WorkflowAware from Products.CMFCore.CMFCatalogAware import WorkflowAware
try: from OFS.role import RoleManager
from OFS.role import RoleManager
except ImportError:
# Zope <=2.12
from AccessControl.Role import RoleManager
COMMENT_TITLE = _(u"comment_title", COMMENT_TITLE = _(u"comment_title",

View File

@ -5,18 +5,14 @@
""" """
import doctest import doctest
try: import unittest2 as unittest
import unittest2 as unittest import pprint
import pprint
from plone.testing import layered from plone.testing import layered
from plone.app.discussion.testing import \ from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING
PLONE4 = True
except ImportError:
import unittest
PLONE4 = False
optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE) optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE)
normal_testfiles = [ normal_testfiles = [
@ -24,9 +20,7 @@ normal_testfiles = [
'functional_test_comment_review_workflow.txt' 'functional_test_comment_review_workflow.txt'
] ]
if PLONE4: def test_suite():
def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTests([ suite.addTests([
layered(doctest.DocFileSuite(test , layered(doctest.DocFileSuite(test ,
@ -38,10 +32,3 @@ if PLONE4:
for test in normal_testfiles]) for test in normal_testfiles])
return suite return suite
else:
def test_suite():
return unittest.TestSuite([])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')