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


Python ordered.OrderedBTreeFolderBase类代码示例

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


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

示例1: create

 def create(self):
     folder = OrderedBTreeFolderBase("f1")
     folder._setOb('o1', DummyObject('o1', 'mt1'))
     folder._setOb('o2', DummyObject('o2', 'mt2'))
     folder._setOb('o3', DummyObject('o3', 'mt1'))
     folder._setOb('o4', DummyObject('o4', 'mt2'))
     return folder
开发者ID:Vinsurya,项目名称:Plone,代码行数:7,代码来源:test_dict_interface.py

示例2: test_getitem

 def test_getitem(self):
     folder = OrderedBTreeFolderBase("f1")
     foo = DummyObject("foo")
     folder._setOb("foo", foo)
     self.assertEqual(folder["foo"], foo)
     self.assertEqual(folder.__getitem__("foo"), foo)
     self.assertRaises(KeyError, folder.__getitem__, "bar")
开发者ID:plone,项目名称:plone.folder,代码行数:7,代码来源:test_dict_interface.py

示例3: test_delitem

 def test_delitem(self):
     folder = OrderedBTreeFolderBase("f1")
     folder._setOb('foo', DummyObject('foo'))
     folder._setOb('bar', DummyObject('bar'))
     self.assertEquals(len(folder.objectIds()), 2)
     del folder['foo']
     del folder['bar']
     self.assertEquals(len(folder.objectIds()), 0)
开发者ID:Vinsurya,项目名称:Plone,代码行数:8,代码来源:test_dict_interface.py

示例4: test_to_verify_ticket_9120

 def test_to_verify_ticket_9120(self):
     folder = OrderedBTreeFolderBase("f1")
     folder['ob1'] = ob1 = DummyObject('ob1')
     folder['ob2'] = ob2 = DummyObject('ob2')
     folder['ob3'] = ob3 = DummyObject('ob3')
     folder['ob4'] = ob4 = DummyObject('ob4')
     del folder['ob2']
     del folder['ob3']
     self.assertEquals(folder.keys(), ['ob1', 'ob4'])
     self.assertEquals(map(aq_base, folder.values()), [ob1, ob4])
     self.assertEquals([key in folder for key in folder], [True, True])
开发者ID:Vinsurya,项目名称:Plone,代码行数:11,代码来源:test_dict_interface.py

示例5: test_to_verify_ticket_9120

 def test_to_verify_ticket_9120(self):
     folder = OrderedBTreeFolderBase("f1")
     folder["ob1"] = ob1 = DummyObject("ob1")
     folder["ob2"] = DummyObject("ob2")
     folder["ob3"] = DummyObject("ob3")
     folder["ob4"] = ob4 = DummyObject("ob4")
     del folder["ob2"]
     del folder["ob3"]
     self.assertEquals(folder.keys(), ["ob1", "ob4"])
     self.assertEquals(map(aq_base, folder.values()), [ob1, ob4])
     self.assertEquals([key in folder for key in folder], [True, True])
开发者ID:plone,项目名称:plone.folder,代码行数:11,代码来源:test_dict_interface.py

示例6: testDeleteSpeed

    def testDeleteSpeed(self):
        folder = OrderedBTreeFolderBase("f1")
        for idx in xrange(100000):
            id = 'foo-%s' % idx
            folder[id] = DummyObject(id, 'bar')
        last = reversed(folder.keys()[-100:])

        @timecall
        def delete():
            for id in last:
                del folder[id]
        delete()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:12,代码来源:benchmarks.py

示例7: create

 def create(self):
     container = OrderedBTreeFolderBase()
     container.setOrdering(u"partial")
     container["o1"] = Orderable("o1", "mt1")
     container["o2"] = Orderable("o2", "mt2")
     container["c1"] = Chaoticle("c1", "mt3")
     container["o3"] = Orderable("o3", "mt1")
     container["c2"] = Chaoticle("c2", "mt2")
     container["c3"] = Chaoticle("c3", "mt1")
     container["o4"] = Orderable("o4", "mt2")
     self.unordered = ["c3", "c2", "c1"]
     ordering = container.getOrdering()
     return container, ordering
开发者ID:plone,项目名称:plone.folder,代码行数:13,代码来源:test_partialordering.py

示例8: create

 def create(self):
     container = OrderedBTreeFolderBase()
     container._ordering = u'unordered'
     container._setOb('o1', DummyObject('o1', 'mt1'))
     container._setOb('o2', DummyObject('o2', 'mt2'))
     container._setOb('o3', DummyObject('o3', 'mt1'))
     container._setOb('o4', DummyObject('o4', 'mt2'))
     return container
开发者ID:plone,项目名称:plone.folder,代码行数:8,代码来源:test_unorderedordering.py

示例9: test_contains

 def test_contains(self):
     folder = OrderedBTreeFolderBase("f1")
     folder._setOb("foo", DummyObject("foo"))
     folder._setOb("bar", DummyObject("bar"))
     self.failUnless("foo" in folder)
     self.failUnless("bar" in folder)
开发者ID:plone,项目名称:plone.folder,代码行数:6,代码来源:test_dict_interface.py

示例10: test_setitem

 def test_setitem(self):
     folder = OrderedBTreeFolderBase("f1")
     foo = DummyObject('foo')
     folder['foo'] = foo
     self.assertEqual(folder._getOb('foo'), foo)
开发者ID:Vinsurya,项目名称:Plone,代码行数:5,代码来源:test_dict_interface.py

示例11: setUp

 def setUp(self):
     self.folder = OrderedBTreeFolderBase("f1")
     self.folder['foo'] = DummyObject('foo', 'mt1')
     self.folder['bar'] = DummyObject('bar', 'mt1')
     self.folder['baz'] = DummyObject('baz', 'mt1')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:5,代码来源:test_ordersupport.py

示例12: PloneOrderSupportTests

class PloneOrderSupportTests(unittest.TestCase):
    """ tests borrowed from Products.CMFPlone.tests.testOrderSupport """

    layer = PLONEFOLDER_INTEGRATION_TESTING

    def setUp(self):
        self.folder = OrderedBTreeFolderBase("f1")
        self.folder['foo'] = DummyObject('foo', 'mt1')
        self.folder['bar'] = DummyObject('bar', 'mt1')
        self.folder['baz'] = DummyObject('baz', 'mt1')

    def testGetObjectPosition(self):
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('bar'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObject(self):
        self.folder.moveObjectToPosition('foo', 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectToSamePos(self):
        self.folder.moveObjectToPosition('bar', 1)
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('bar'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectToFirstPos(self):
        self.folder.moveObjectToPosition('bar', 0)
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectToLastPos(self):
        self.folder.moveObjectToPosition('bar', 2)
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 2)

    def testMoveObjectOutLowerBounds(self):
        # Pos will be normalized to 0
        self.folder.moveObjectToPosition('bar', -1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectOutUpperBounds(self):
        # Pos will be normalized to 2
        self.folder.moveObjectToPosition('bar', 3)
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 2)

    def testMoveObjectsUp(self):
        self.folder.moveObjectsUp(['bar'])
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectsDown(self):
        self.folder.moveObjectsDown(['bar'])
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 2)

    def testMoveObjectsToTop(self):
        self.folder.moveObjectsToTop(['bar'])
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('baz'), 2)

    def testMoveObjectsToBottom(self):
        self.folder.moveObjectsToBottom(['bar'])
        self.assertEqual(self.folder.getObjectPosition('foo'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 2)

    def testMoveTwoObjectsUp(self):
        self.folder.moveObjectsUp(['bar', 'baz'])
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('foo'), 2)

    def testMoveTwoObjectsDown(self):
        self.folder.moveObjectsDown(['foo', 'bar'])
        self.assertEqual(self.folder.getObjectPosition('baz'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
        self.assertEqual(self.folder.getObjectPosition('bar'), 2)

    def testMoveTwoObjectsToTop(self):
        self.folder.moveObjectsToTop(['bar', 'baz'])
        self.assertEqual(self.folder.getObjectPosition('bar'), 0)
        self.assertEqual(self.folder.getObjectPosition('baz'), 1)
        self.assertEqual(self.folder.getObjectPosition('foo'), 2)

    def testMoveTwoObjectsToBottom(self):
        self.folder.moveObjectsToBottom(['foo', 'bar'])
        self.assertEqual(self.folder.getObjectPosition('baz'), 0)
        self.assertEqual(self.folder.getObjectPosition('foo'), 1)
#.........这里部分代码省略.........
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:101,代码来源:test_ordersupport.py

示例13: testSetOrdering

 def testSetOrdering(self):
     folder = OrderedBTreeFolderBase()
     folder.setOrdering('unordered')
     self.failUnless(isinstance(folder.getOrdering(), UnorderedOrdering))
     folder.setOrdering()
     self.failUnless(isinstance(folder.getOrdering(), DefaultOrdering))
开发者ID:pigaov10,项目名称:plone4.3,代码行数:6,代码来源:test_ordering_adapters.py

示例14: testDefaultAdapter

 def testDefaultAdapter(self):
     folder = OrderedBTreeFolderBase()
     self.failUnless(isinstance(folder.getOrdering(), DefaultOrdering))
开发者ID:pigaov10,项目名称:plone4.3,代码行数:3,代码来源:test_ordering_adapters.py

示例15: _checkId

 def _checkId(self, id, allow_dup=0):
     OrderedBTreeFolderBase._checkId(self, id, allow_dup)
     BaseFolder._checkId(self, id, allow_dup)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:3,代码来源:base.py


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