Permalink
Browse files

Allow getTypeInfo to return None

svn path=/plone.app.contentrules/branches/1.1/; revision=26692
  • Loading branch information...
1 parent 878d341 commit 38fc87ce7ad2649fe23855cc15de959d410c316b Helge Tesdal committed Apr 29, 2009
View
@@ -4,6 +4,9 @@ Changelog for plone.app.contentrules
plone.app.contentrules - 1.1.6
+ - Add check to see if getTypeInfo can be None (which is a valid value)
+ [tesdal]
+
- Changed the simplepublish test to use a copy instead of a move action.
The move action causes the content item to be moved away while editing
it and causes a NotFound error. In Plone 3 this is hidden by the
@@ -65,7 +65,10 @@ def __call__(self):
obj = aq_inner(self.event.object)
if not hasattr(aq_base(obj), 'getTypeInfo'):
return False
- return obj.getTypeInfo().getId() in self.element.check_types
+ ti = obj.getTypeInfo() # getTypeInfo can be None
+ if ti is None:
+ return False
+ return ti.getId() in self.element.check_types
class PortalTypeAddForm(AddForm):
"""An add form for portal type conditions.
@@ -59,10 +59,15 @@ def testExecute(self):
ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
self.assertEquals(True, ex())
-
+
ex = getMultiAdapter((self.portal, e, DummyEvent(self.portal)), IExecutable)
self.assertEquals(False, ex())
-
+
+ self.folder.portal_types = None
+ ex = getMultiAdapter((self.portal, e, DummyEvent(self.folder)), IExecutable)
+ self.assertEquals(False, ex())
+
+
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()

0 comments on commit 38fc87c

Please sign in to comment.