本文整理汇总了Python中Products.CMFPlone.interfaces.ISelectableConstrainTypes.setLocallyAllowedTypes方法的典型用法代码示例。如果您正苦于以下问题:Python ISelectableConstrainTypes.setLocallyAllowedTypes方法的具体用法?Python ISelectableConstrainTypes.setLocallyAllowedTypes怎么用?Python ISelectableConstrainTypes.setLocallyAllowedTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFPlone.interfaces.ISelectableConstrainTypes
的用法示例。
在下文中一共展示了ISelectableConstrainTypes.setLocallyAllowedTypes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testNonStructualFolderShowsParent
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def testNonStructualFolderShowsParent(self):
self.folder.invokeFactory('Folder', 'folder1')
directlyProvides(self.folder.folder1, INonStructuralFolder)
constraints = ISelectableConstrainTypes(self.folder.folder1)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder.folder1, self.request)
self.assertEqual(len(actions), 0)
示例2: testMoreNotIncludedWhenNotNecessary
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def testMoreNotIncludedWhenNotNecessary(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder, self.request)
self.assertEqual(len(actions), 2)
self.assertEqual(actions[0]['extra']['id'], 'document')
self.assertEqual(actions[1]['extra']['id'], 'settings')
示例3: testMoreIncluded
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def testMoreIncluded(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document', 'Image',))
constraints.setImmediatelyAddableTypes(('Document',))
actions = self.menu.getMenuItems(self.folder, self.request)
self.failIf('image' in [a['extra']['id'] for a in actions])
self.failUnless('document' in [a['extra']['id'] for a in actions])
self.failUnless('more' in [a['extra']['id'] for a in actions])
self.failUnless('settings' in [a['extra']['id'] for a in actions])
示例4: handleSave
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def handleSave(self, action):
data, errors = self.extractData()
if errors:
return
immediately_addable_types = [t for t in data['current_prefer']
if t not in data['current_allow']]
locally_allowed_types = data['current_prefer']
aspect = ISelectableConstrainTypes(self.context)
aspect.setConstrainTypesMode(data['constrain_types_mode'])
aspect.setLocallyAllowedTypes(locally_allowed_types)
aspect.setImmediatelyAddableTypes(immediately_addable_types)
示例5: testAddMenuWithNothingToAddButWithAvailableMorePage
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def testAddMenuWithNothingToAddButWithAvailableMorePage(self):
constraints = ISelectableConstrainTypes(self.folder)
constraints.setConstrainTypesMode(1)
constraints.setLocallyAllowedTypes(('Document',))
constraints.setImmediatelyAddableTypes(())
self.folder.manage_permission('Modify constrain types', ('Manager',))
setRoles(self.portal, TEST_USER_ID, ['Contributor'])
items = self.menu.getMenuItems(self.folder, self.request)
factoriesMenuItem = [i for i in items if
i['extra']['id'] == 'plone-contentmenu-factories'][0]
self.assertEqual(len(factoriesMenuItem['submenu']), 1)
self.assertEqual(factoriesMenuItem['submenu'][0]['extra']['id'],
'plone-contentmenu-more')
示例6: __call__
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def __call__(self):
if hasattr(self.context.aq_base, CAROUSEL_ID):
carousel = getattr(self.context, CAROUSEL_ID)
else:
pt = getToolByName(self.context, 'portal_types')
newid = pt.constructContent(
type_name='Folder',
container=self.context,
id='carousel',
title='Carousel Banners'
)
carousel = getattr(self.context, newid)
# exclude the (Archetypes or Dexterity) folder from navigation
if hasattr(aq_base(carousel), 'setExcludeFromNav'):
carousel.setExcludeFromNav(True)
elif hasattr(aq_base(carousel), 'exclude_from_nav'):
carousel.exclude_from_nav = True
# mark the new folder as a Carousel folder
alsoProvides(carousel, ICarouselFolder)
# make sure Carousel banners are addable within the new folder
addPermissionsForRole(carousel, 'Manager',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Site Administrator',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Owner',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Contributor',
('Carousel: Add Carousel Banner',))
addPermissionsForRole(carousel, 'Editor',
('Carousel: Add Carousel Banner',))
# make sure *only* Carousel banners are addable
aspect = ISelectableConstrainTypes(carousel)
aspect.setConstrainTypesMode(1)
aspect.setLocallyAllowedTypes(['Carousel Banner'])
aspect.setImmediatelyAddableTypes(['Carousel Banner'])
carousel.reindexObject()
self.request.RESPONSE.redirect(
carousel.absolute_url() + '/@@edit-carousel'
)
示例7: handleSave
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def handleSave(self, action):
data, errors = self.extractData()
if errors:
self.status = self.formErrorsMessage
return
allowed_types = data['allowed_types']
immediately_addable = [
t for t in allowed_types
if t not in data['secondary_types']]
aspect = ISelectableConstrainTypes(self.context)
aspect.setConstrainTypesMode(data['constrain_types_mode'])
aspect.setLocallyAllowedTypes(allowed_types)
aspect.setImmediatelyAddableTypes(immediately_addable)
contextURL = self.context.absolute_url()
self.request.response.redirect(contextURL)
示例8: test_create_constraints
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def test_create_constraints(self):
"""Test the constraints when creating content."""
from plone.api.exc import InvalidParameterError
from plone.api.exc import MissingParameterError
# This will definitely fail
with self.assertRaises(MissingParameterError):
api.content.create()
# Check the constraints for the type container
with self.assertRaises(MissingParameterError):
api.content.create(
type='Document',
id='test-doc',
)
# Check the constraints for the type parameter
container = mock.Mock()
with self.assertRaises(MissingParameterError):
api.content.create(
container=container,
id='test-doc',
)
# Check the constraints for id and title parameters
with self.assertRaises(MissingParameterError):
api.content.create(
container=container,
type='Document',
)
# Check the constraints for allowed types in the container
container = self.events
with self.assertRaises(InvalidParameterError):
api.content.create(
container=container,
type='foo',
id='test-foo',
)
# Check the constraints for allowed types in the container if
# the container is the portal
container = self.portal
with self.assertRaises(InvalidParameterError) as cm:
api.content.create(
container=container,
type='foo',
id='test-foo',
)
# Check if the underlying error message is included
# in the InvalidParameterError message
self.assertIn(
'No such content type: foo',
str(cm.exception),
)
# Check the constraints for allowed types in the container
# Create a folder
folder = api.content.create(
container=container,
type='Folder',
id='test-folder',
)
assert folder
# Constraint the allowed types
ENABLED = 1
if getattr(aq_base(folder), 'setConstrainTypesMode', None): # AT
folder.setConstrainTypesMode(ENABLED)
folder.setLocallyAllowedTypes(('News Item', ))
else: # DX
from Products.CMFPlone.interfaces import ISelectableConstrainTypes
constraints = ISelectableConstrainTypes(folder)
constraints.setConstrainTypesMode(ENABLED)
constraints.setLocallyAllowedTypes(('News Item', ))
with self.assertRaises(InvalidParameterError):
api.content.create(
container=folder,
type='Document',
id='test-doc',
)
示例9: migrate_typerestriction
# 需要导入模块: from Products.CMFPlone.interfaces import ISelectableConstrainTypes [as 别名]
# 或者: from Products.CMFPlone.interfaces.ISelectableConstrainTypes import setLocallyAllowedTypes [as 别名]
def migrate_typerestriction(self):
constraints = ISelectableConstrainTypes(self.new)
constraints.setConstrainTypesMode(ENABLED)
constraints.setImmediatelyAddableTypes(self.new_allowed)
constraints.setLocallyAllowedTypes(self.new_allowed)