本文整理汇总了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
示例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")
示例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)
示例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])
示例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])
示例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()
示例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
示例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
示例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)
示例10: test_setitem
def test_setitem(self):
folder = OrderedBTreeFolderBase("f1")
foo = DummyObject('foo')
folder['foo'] = foo
self.assertEqual(folder._getOb('foo'), foo)
示例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')
示例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)
#.........这里部分代码省略.........
示例13: testSetOrdering
def testSetOrdering(self):
folder = OrderedBTreeFolderBase()
folder.setOrdering('unordered')
self.failUnless(isinstance(folder.getOrdering(), UnorderedOrdering))
folder.setOrdering()
self.failUnless(isinstance(folder.getOrdering(), DefaultOrdering))
示例14: testDefaultAdapter
def testDefaultAdapter(self):
folder = OrderedBTreeFolderBase()
self.failUnless(isinstance(folder.getOrdering(), DefaultOrdering))
示例15: _checkId
def _checkId(self, id, allow_dup=0):
OrderedBTreeFolderBase._checkId(self, id, allow_dup)
BaseFolder._checkId(self, id, allow_dup)