当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.ISelectableConstrainTypes类代码示例

本文整理汇总了Python中Products.CMFPlone.interfaces.ISelectableConstrainTypes的典型用法代码示例。如果您正苦于以下问题:Python ISelectableConstrainTypes类的具体用法?Python ISelectableConstrainTypes怎么用?Python ISelectableConstrainTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ISelectableConstrainTypes类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_isMixedIn

 def test_isMixedIn(self):
     self.assertTrue(
         isinstance(self.af, constraintypes.ConstrainTypesMixin),
         "ConstrainTypesMixin was not mixed in to ATFolder")
     self.assertTrue(
         ISelectableConstrainTypes.providedBy(self.af),
         "ISelectableConstrainTypes not implemented by ATFolder instance")
开发者ID:plone,项目名称:Products.ATContentTypes,代码行数:7,代码来源:test_constraintypes.py

示例2: test_isMixedIn

 def test_isMixedIn(self):
     self.failUnless(isinstance(self.af,
                                constraintypes.ConstrainTypesMixin),
                     "ConstrainTypesMixin was not mixed in to ATFolder")
     self.failUnless(ZopeTwoISelectableConstrainTypes.isImplementedBy(self.af),
                     "ISelectableConstrainTypes not implemented by ATFolder instance")
     self.failUnless(ISelectableConstrainTypes.providedBy(self.af),
                     "ISelectableConstrainTypes not implemented by ATFolder instance")
开发者ID:dtgit,项目名称:dtedu,代码行数:8,代码来源:test_constraintypes.py

示例3: FormContentAdapter

class FormContentAdapter(object):

    def __init__(self, context):
        self.context = ISelectableConstrainTypes(context)

    @property
    def constrain_types_mode(self):
        return self.context.getConstrainTypesMode()

    @property
    def allowed_types(self):
        return self.context.getLocallyAllowedTypes()

    @property
    def secondary_types(self):
        immediately_addable = self.context.getImmediatelyAddableTypes()
        return [t for t in self.context.getLocallyAllowedTypes()
                if t not in immediately_addable]
开发者ID:urska19,项目名称:Plone-test,代码行数:18,代码来源:constraintypes.py

示例4: testNonStructualFolderShowsParent

 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)
开发者ID:pingviini,项目名称:plone.app.contentmenu,代码行数:9,代码来源:tests.py

示例5: testMoreNotIncludedWhenNotNecessary

 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')
开发者ID:pingviini,项目名称:plone.app.contentmenu,代码行数:9,代码来源:tests.py

示例6: testMoreIncluded

 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])
开发者ID:pingviini,项目名称:plone.app.contentmenu,代码行数:10,代码来源:tests.py

示例7: testAddMenuWithNothingToAddButWithAvailableMorePage

 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')
开发者ID:starzel,项目名称:plone.app.contentmenu,代码行数:13,代码来源:test_menu.py

示例8: handleSave

    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)
开发者ID:starzel,项目名称:plone.app.content,代码行数:13,代码来源:constraintypes.py

示例9: __call__

    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'
        )
开发者ID:pabo3000,项目名称:Products.Carousel,代码行数:47,代码来源:manager.py

示例10: handleSave

    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)
开发者ID:urska19,项目名称:Plone-test,代码行数:17,代码来源:constraintypes.py

示例11: __init__

 def __init__(self, context):
     self.context = ISelectableConstrainTypes(context)
开发者ID:urska19,项目名称:Plone-test,代码行数:2,代码来源:constraintypes.py

示例12: migrate_typerestriction

 def migrate_typerestriction(self):
     constraints = ISelectableConstrainTypes(self.new)
     constraints.setConstrainTypesMode(ENABLED)
     constraints.setImmediatelyAddableTypes(self.new_allowed)
     constraints.setLocallyAllowedTypes(self.new_allowed)
开发者ID:zestsoftware,项目名称:Products.eXtremeManagement,代码行数:5,代码来源:setuphandlers.py

示例13: __call__

 def __call__(self, context):
     constrain_aspect = ISelectableConstrainTypes(context)
     items = []
     for type_ in constrain_aspect.getDefaultAddableTypes():
         items.append(SimpleTerm(value=type_.getId(), title=type_.Title()))
     return SimpleVocabulary(items)
开发者ID:starzel,项目名称:plone.app.content,代码行数:6,代码来源:constraintypes.py

示例14: test_create_constraints

    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',
            )
开发者ID:plone,项目名称:plone.api,代码行数:83,代码来源:test_content.py


注:本文中的Products.CMFPlone.interfaces.ISelectableConstrainTypes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。