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


Python Folder.objectIds方法代码示例

本文整理汇总了Python中OFS.Folder.Folder.objectIds方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.objectIds方法的具体用法?Python Folder.objectIds怎么用?Python Folder.objectIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OFS.Folder.Folder的用法示例。


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

示例1: VHMAddingTests

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import objectIds [as 别名]
class VHMAddingTests(unittest.TestCase):

    def setUp(self):
        from OFS.Folder import Folder
        super(VHMAddingTests, self).setUp()
        self.root = Folder('root')

    def _makeOne(self):
        from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
        return VirtualHostMonster()

    def test_add_with_existing_vhm(self):
        from Products.SiteAccess.VirtualHostMonster import \
            manage_addVirtualHostMonster
        from zExceptions import BadRequest
        vhm1 = self._makeOne()
        vhm1.manage_addToContainer(self.root)

        vhm2 = self._makeOne()
        self.assertRaises(BadRequest, vhm2.manage_addToContainer, self.root)
        self.assertRaises( BadRequest
                         , manage_addVirtualHostMonster
                         , self.root
                         )

    def test_add_id_collision(self):
        from OFS.Folder import Folder
        from Products.SiteAccess.VirtualHostMonster import \
            manage_addVirtualHostMonster
        from zExceptions import BadRequest
        self.root._setObject('VHM', Folder('VHM'))
        vhm1 = self._makeOne()

        self.assertRaises(BadRequest, vhm1.manage_addToContainer, self.root)
        self.assertRaises( BadRequest
                         , manage_addVirtualHostMonster
                         , self.root
                         )

    def test_add_addToContainer(self):
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        vhm1 = self._makeOne()
        vhm1.manage_addToContainer(self.root)

        self.assertTrue(vhm1.getId() in self.root.objectIds())
        self.assertTrue(queryBeforeTraverse(self.root, vhm1.meta_type))

    def test_add_manage_addVirtualHostMonster(self):
        from Products.SiteAccess.VirtualHostMonster import \
            manage_addVirtualHostMonster
        from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        manage_addVirtualHostMonster(self.root)

        self.assertTrue(VirtualHostMonster.id in self.root.objectIds())
        hook = queryBeforeTraverse(self.root, VirtualHostMonster.meta_type)
        self.assertTrue(hook)
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:59,代码来源:testVirtualHostMonster.py

示例2: testAllowGroupsAttribute

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import objectIds [as 别名]
 def testAllowGroupsAttribute(self):
     # Verify that __allow_groups__ gets set and removed
     from OFS.Folder import Folder
     f = Folder()
     zcuf = self._makeOne()
     f._setObject(zcuf.getId(), zcuf)
     self.assert_(zcuf.getId() in f.objectIds())
     self.assert_(aq_base(f.__allow_groups__) is aq_base(f.acl_users))
     f._delObject(zcuf.getId())
     self.assert_(not zcuf.getId() in f.objectIds())
开发者ID:goschtl,项目名称:zope,代码行数:12,代码来源:test_PluggableAuthService.py

示例3: objectIds

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import objectIds [as 别名]
    def objectIds(self, spec=None):
        """ this is a patch for pre-2.4 Zope installations. Such
            installations don't have an entry for the WebDAV LockManager
            introduced in 2.4.
        """

        meta_types = map(lambda x: x.get('meta_type',None) , self._objects)

        if not self.DavLocks.meta_type in meta_types:

            lst = list(self._objects)
            lst.append(  {'id': 'DavLocks', \
                'meta_type': self.DavLocks.meta_type})
            self._objects = tuple(lst)

        return Folder.objectIds(self, spec)
开发者ID:wpjunior,项目名称:proled,代码行数:18,代码来源:ApplicationManager.py

示例4: TestOrderFolder

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import objectIds [as 别名]
class TestOrderFolder(unittest.TestCase):

    def setUp(self):
        self.folder = Folder('folder1')
        manage_addFolder(self.folder, 'folder11')
        manage_addFolder(self.folder, 'folder12')
        manage_addFolder(self.folder, 'folder13')
        self.db = DB(MappingStorage())
        self.connection = self.db.open()

    def tearDown(self):
        self.db.close()

    def test_basic(self):
        """ Let's create a folder with a few objects and change their order """
        order_seq = ['folder11', 'folder13', 'folder12']
        folderutils.sort_folder(self.folder, order_seq)
        self.assertEqual(self.folder.objectIds(), order_seq)

    def test_unchanged(self):
        """ Nothing changes """
        order_seq = self.folder.objectIds()
        folderutils.sort_folder(self.folder, order_seq)
        self.assertEqual(self.folder.objectIds(), order_seq)

    def test_incomplete(self):
        """ Some ids from the folder are missing in the call. This means that
        the folder must be reordered and the missing ids must be put at the
        end."""

        order_seq = ['folder13', 'folder12']
        folderutils.sort_folder(self.folder, order_seq)
        self.assertEqual(self.folder.objectIds(), order_seq + ['folder11'])

    def test_extra_id(self):
        """ An ID that is not inside the folder """

        order_seq = ['folder13', 'asdf']
        folderutils.sort_folder(self.folder, order_seq)
        self.assertEqual(self.folder.objectIds(),
                         ['folder13', 'folder11', 'folder12'])

    def test_no_unnecessary_commit(self):
        order_seq = self.folder.objectIds()
        folderutils.sort_folder(self.folder, order_seq)

        root = self.connection.root()
        root['folder'] = self.folder
        transaction.commit()

        order_seq.pop() # resulting order should be the same
        folderutils.sort_folder(self.folder, order_seq)
        # assert no commit to DB since no change was required by ordering
        self.assertEqual(self.connection._registered_objects, [])
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:56,代码来源:test_folderutils.py


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