File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""Module that provides functionality for content manipulation."""
2
2
3
+ from AccessControl import Unauthorized
3
4
from copy import copy as _copy
4
5
from plone .api import portal
5
6
from plone .api .exc import InvalidParameterError
13
14
from plone .uuid .interfaces import IUUID
14
15
from Products .CMFCore .DynamicType import DynamicType
15
16
from Products .CMFCore .WorkflowCore import WorkflowException
16
- from zope .component import ComponentLookupError
17
17
from Products .CMFPlone .interfaces import IConstrainTypes
18
18
from zExceptions import BadRequest
19
+ from zope .component import ComponentLookupError
19
20
from zope .component import getMultiAdapter
20
21
from zope .component import getSiteManager
21
22
from zope .container .interfaces import INameChooser
@@ -76,7 +77,7 @@ def create(
76
77
# For dexterity objects we want to not use the invokeFactory
77
78
# method because we want to have the id generated by the name chooser
78
79
if not fti .isConstructionAllowed (container ):
79
- raise ValueError (f"Cannot create { type } " )
80
+ raise Unauthorized (f"Cannot create { type } " )
80
81
81
82
container_fti = container .getTypeInfo ()
82
83
if container_fti is not None and not container_fti .allowType (type ):
Original file line number Diff line number Diff line change @@ -387,6 +387,18 @@ def test_create_with_not_lowercase_id(self):
387
387
)
388
388
self .assertEqual (obj .id , "Doc1" )
389
389
390
+ def test_create_anonymous_unauthorized (self ):
391
+ from AccessControl import Unauthorized
392
+ from plone .app .testing import logout
393
+
394
+ logout ()
395
+ with self .assertRaises (Unauthorized ):
396
+ api .content .create (
397
+ container = self .portal ,
398
+ type = "Dexterity Item" ,
399
+ id = "foo" ,
400
+ )
401
+
390
402
def test_create_raises_unicodedecodeerror (self ):
391
403
"""Test that the create method raises UnicodeDecodeErrors correctly."""
392
404
site = getGlobalSiteManager ()
You can’t perform that action at this time.
0 commit comments