Merge pull request #154 from plone/attributeerror

Catch AttributeError in ``api.content.get``
This commit is contained in:
Adam Forsythe-Cheasley 2013-12-23 03:11:08 -08:00
commit 4ecfb83a30
3 changed files with 8 additions and 1 deletions

View File

@ -6,9 +6,13 @@ Changelog
- Add ``api.env.plone_version()`` and ``api.env.zope_version()`` refs. #126.
[hvelarde]
- Stop UnicodeDecodeErrors being swallowed in ``api.content.create``
[mattss]
- Catch AttributeError in ``api.content.get`` (raised if only part of the
traversal path exists)
[mattss]
1.1.0 (2013-10-12)
------------------

View File

@ -136,7 +136,7 @@ def get(path=None, UID=None):
try:
return site.restrictedTraverse(path)
except KeyError:
except (KeyError, AttributeError):
return None # When no object is found don't raise an error
elif UID:

View File

@ -305,6 +305,9 @@ class TestPloneApiContent(unittest.TestCase):
self.assertFalse(api.content.get('/spam/ham'))
self.assertFalse(api.content.get(UID='bacon'))
# Test getting a non-existing subfolder by path
self.assertFalse(api.content.get('/about/spam'))
def test_move_constraints(self):
"""Test the constraints for moving content."""
from plone.api.exc import MissingParameterError