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.fieldsets import extensible
# starting from 0.6.0 version plone.z3cform has IWrappedForm interface
try:
from plone.z3cform.interfaces import IWrappedForm
HAS_WRAPPED_FORM = True
except ImportError: # pragma: no cover
HAS_WRAPPED_FORM = False
from plone.z3cform.interfaces import IWrappedForm
COMMENT_DESCRIPTION_PLAIN_TEXT = _(
u"comment_description_plain_text",
@ -265,8 +261,7 @@ class CommentsViewlet(ViewletBase):
super(CommentsViewlet, self).update()
z2.switch_on(self, request_layer=IFormLayer)
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()
# view methods

View File

@ -16,10 +16,8 @@ from plone.app.discussion.interfaces import IConversation, IComment
from plone.indexer import indexer
try:
from plone.uuid.interfaces import IUUID
except ImportError:
IUUID = None
from plone.uuid.interfaces import IUUID
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 WorkflowAware
try:
from OFS.role import RoleManager
except ImportError:
# Zope <=2.12
from AccessControl.Role import RoleManager
from OFS.role import RoleManager
COMMENT_TITLE = _(u"comment_title",

View File

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