Merge pull request #21 from khink/master
Fix conversation view: shouldn't break on invalid URLs
This commit is contained in:
		
						commit
						df7e6978ba
					
				@ -4,6 +4,10 @@ Changelog
 | 
			
		||||
2.2.1 (unreleased)
 | 
			
		||||
------------------
 | 
			
		||||
 | 
			
		||||
- Make conversation view not break when comment-id cannot be converted to long.
 | 
			
		||||
  Fixes #13327
 | 
			
		||||
  [khink]
 | 
			
		||||
 | 
			
		||||
- fix insufficient privileges when trying to view
 | 
			
		||||
  the RSS feed of a comment collection
 | 
			
		||||
  [maartenkling]
 | 
			
		||||
 | 
			
		||||
@ -210,7 +210,11 @@ class Conversation(Traversable, Persistent, Explicit):
 | 
			
		||||
    def __getitem__(self, key):
 | 
			
		||||
        """Get an item by its long key
 | 
			
		||||
        """
 | 
			
		||||
        return self._comments[long(key)].__of__(self)
 | 
			
		||||
        try:
 | 
			
		||||
            comment_id = long(key)
 | 
			
		||||
        except ValueError:
 | 
			
		||||
            return
 | 
			
		||||
        return self._comments[comment_id].__of__(self)
 | 
			
		||||
 | 
			
		||||
    def __delitem__(self, key, suppress_container_modified=False):
 | 
			
		||||
        """Delete an item by its long key
 | 
			
		||||
 | 
			
		||||
@ -699,6 +699,14 @@ class ConversationTest(unittest.TestCase):
 | 
			
		||||
        self.assertEqual('http://nohost/plone/doc1/++conversation++default',
 | 
			
		||||
                          conversation.absolute_url())
 | 
			
		||||
 | 
			
		||||
    def test_unconvertible_id(self):
 | 
			
		||||
        # make sure the conversation view doesn't break when given comment id
 | 
			
		||||
        # can't be converted to long
 | 
			
		||||
 | 
			
		||||
        conversation = self.portal.doc1.restrictedTraverse(
 | 
			
		||||
            '++conversation++default/ThisCantBeRight')
 | 
			
		||||
        self.assertEqual(conversation, None)
 | 
			
		||||
 | 
			
		||||
    def test_parent(self):
 | 
			
		||||
        # Check that conversation has a content object as parent
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ optionflags = (
 | 
			
		||||
    doctest.REPORT_ONLY_FIRST_FAILURE)
 | 
			
		||||
normal_testfiles = [
 | 
			
		||||
    'functional_test_comments.txt',
 | 
			
		||||
    'functional_test_comment_review_workflow.txt'
 | 
			
		||||
    'functional_test_comment_review_workflow.txt',
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user