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


Python Folder.id方法代码示例

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


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

示例1: test_store

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_store(self):
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = Folder()
            f.id = 'Holidays'
            app._setObject(f.id, f, set_owner=0)
            transaction.commit()

            f2 = Folder()
            f2.id = 'Christmas'
            f._setObject(f2.id, f2, set_owner=0)
            transaction.commit()

            f3 = Folder()
            f3.id = 'Eve'
            f2._setObject(f3.id, f3, set_owner=0)
            transaction.commit()

            conn2 = self.db.open()
            try:
                app = conn2.root()['Application']
                self.assert_(hasattr(app, 'Holidays'))
                self.assert_(hasattr(app.Holidays, 'Christmas'))
                self.assert_(hasattr(app.Holidays.Christmas, 'Eve'))
                # Verify the same OID is seen in both connections.
                self.assertEqual(app.Holidays._p_oid, f._p_oid)
            finally:
                conn2.close()

        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:34,代码来源:zope2testbase.py

示例2: test_upo_state_after_deactivate

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_upo_state_after_deactivate(self):
        # An unmanaged persistent object that gets deactivated
        # and reactivated should have the most recent state.
        self.db.setCacheSize(10)  # Don't flush the objects at commit
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = Folder()
            f.id = 'Holidays'
            f.stowaway = Folder()
            f.stowaway.id = 'stowaway'
            f.stowaway._prop = 'value1'
            app._setObject(f.id, f, set_owner=0)
            transaction.commit()
            self.assertEqual(f._p_changed, 0)

            self.assertEqual(f.stowaway._p_oid, 'unmanaged')
            f.stowaway._prop = 'value2'
            transaction.commit()
            self.assertEqual(f._p_changed, 0)

            del f.stowaway._p_changed
            self.assertEqual(f.stowaway._p_changed, None)
            self.assertEqual(f.stowaway._prop, 'value2')
        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:28,代码来源:zope2testbase.py

示例3: test_store_properties

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_store_properties(self):
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = Folder()
            f.id = 'Holidays'
            f.title = 'Holiday Calendar'
            app._setObject(f.id, f, set_owner=0)
            transaction.commit()

            f._setProperty('pi', 3.14, 'float')
            f._setProperty('stuff', ['a', 'bc', 'd'], 'lines')
            transaction.commit()

            conn2 = self.db.open()
            try:
                app = conn2.root()['Application']
                self.assert_(hasattr(app, 'Holidays'))
                got = 0
                for k, v in app.Holidays.propertyItems():
                    if k == 'title':
                        got += 1
                        self.assertEqual(v, 'Holiday Calendar')
                    elif k == 'pi':
                        got += 1
                        self.assertEqual(v, 3.14)
                    elif k == 'stuff':
                        got += 1
                        self.assertEqual(tuple(v), ('a', 'bc', 'd'))
                self.assertEqual(got, 3)
            finally:
                conn2.close()

        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:37,代码来源:zope2testbase.py

示例4: test_anyfolder_storage

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_anyfolder_storage(self):
        # Try to store a folderish object of an otherwise unknown class
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = Folder()
            f.id = 'Holidays'
            app._setObject(f.id, f, set_owner=0)
            transaction.commit()

            f2 = TestFolder("New Year's Eve")
            f2.id = 'NewYear'
            f._setObject(f2.id, f2, set_owner=0)
            transaction.commit()

            # Verify the object is in its own database record
            self.assertNotEqual(f2._p_oid, None)
            f2._p_changed = None
            self.assert_(f2._p_changed is None)

            # Verify the ability to load it
            conn2 = self.db.open()
            try:
                app2 = conn2.root()['Application']
                ff = app2.Holidays.NewYear
                self.assertEqual(ff.title, "New Year's Eve")
                self.assertEqual(ff.__class__, TestFolder)
            finally:
                conn2.close()
        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:33,代码来源:zope2testbase.py

示例5: manage_addMounts

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
def manage_addMounts(dispatcher, paths=(), create_mount_points=True,
                     REQUEST=None):
    """Adds MountedObjects at the requested paths.
    """
    count = 0
    app = dispatcher.getPhysicalRoot()
    for path in paths:
        mo = MountedObject(path)
        mo._create_mount_points = not not create_mount_points
        # Raise an error now if there is any problem.
        mo._test(app)
        blazer = SimpleTrailblazer(app)
        container = blazer.traverseOrConstruct(path, omit_final=1)
        container._p_jar.add(mo)
        loaded = mo.__of__(container)

        # Add a faux object to avoid generating manage_afterAdd() events
        # while appeasing OFS.ObjectManager._setObject(), then discreetly
        # replace the faux object with a MountedObject.
        faux = Folder()
        faux.id = mo.id
        faux.meta_type = loaded.meta_type
        container._setObject(faux.id, faux)
        # DM 2005-05-17: we want to keep our decision about automatic
        #  mount point creation
        #del mo._create_mount_points
        container._setOb(faux.id, mo)
        setMountPoint(container, faux.id, mo)
        count += 1
    if REQUEST is not None:
        REQUEST['RESPONSE'].redirect(
            REQUEST['URL1'] + ('/manage_main?manage_tabs_message='
            'Added %d mount points.' % count))
开发者ID:CedricEdouardKassi,项目名称:Zope,代码行数:35,代码来源:MountedObject.py

示例6: testGenerateIdDenialOfServicePrevention

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
 def testGenerateIdDenialOfServicePrevention(self):
     for n in range(10):
         item = Folder()
         item.id = "item%d" % n
         self.f._setOb(item.id, item)
     self.f.generateId("item", rand_ceiling=20)  # Shouldn't be a problem
     self.assertRaises(ExhaustedUniqueIdsError, self.f.generateId, "item", rand_ceiling=9)
开发者ID:eaudeweb,项目名称:naaya,代码行数:9,代码来源:testBTreeFolder2.py

示例7: test_btreefolder2

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_btreefolder2(self):
        from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = BTreeFolder2('Holidays')
            f.id = 'Holidays'
            app._setObject(f.id, f, set_owner=0)
            f2 = Folder()
            f2.id = 'Easter'
            app.Holidays._setObject(f2.id, f2)
            transaction.commit()
            # Verify serialize() found the unmanaged subobjects.
            self.assertEqual(app.Holidays._tree._p_oid, 'unmanaged')
            # Sanity check
            self.assertEqual(app.Holidays.objectCount(), 1)

            conn2 = self.db.open()
            try:
                app2 = conn2.root()['Application']
                self.assert_(app2.Holidays._tree.has_key('Easter'))
                self.assert_(not app2.Holidays.__dict__.has_key('Easter'))
                # Verify deserialize() found the unmanaged subobjects.
                self.assertEqual(app2.Holidays._tree._p_oid, 'unmanaged')
                app2.Holidays._delObject('Easter')
                transaction.commit()
            finally:
                conn2.close()

            # The deletion should be seen by both connections.
            conn.sync()
            self.assertEqual(app.Holidays.objectCount(), 0)

        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:37,代码来源:zope2testbase.py

示例8: test_rename

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def test_rename(self):
        conn = self.db.open()
        try:
            app = conn.root()['Application']
            f = Folder()
            f.id = 'Holidays'
            app._setObject(f.id, f, set_owner=0)
            transaction.commit()

            # Do what manage_rename does, without the security checks
            ob = app.Holidays.aq_base
            app._delObject('Holidays')
            ob._setId('HolidayCalendar')
            app._setObject(ob.id, ob, set_owner=0)
            transaction.commit()

            self.assert_(hasattr(app, 'HolidayCalendar'))
            self.assert_(not hasattr(app, 'Holidays'))

            conn2 = self.db.open()
            try:
                app = conn2.root()['Application']
                self.assert_(hasattr(app, 'HolidayCalendar'))
                self.assert_(not hasattr(app, 'Holidays'))
            finally:
                conn2.close()

        finally:
            conn.close()
开发者ID:goschtl,项目名称:zope,代码行数:31,代码来源:zope2testbase.py

示例9: setUp

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
 def setUp(self):
     f1 = Folder()
     f1.id = 'f1'
     self.f1 = f1
     f2 = Folder()
     f2.id = 'f2'
     self.f1.f2 = f2
     f3 = Folder()
     f3.id = 'f3'
     self.f1.f2.f3 = f3
     f4 = Folder()
     f4.id = 'f4'
     self.f1.f2.f4 = f4
     f4_1 = Folder()
     f4_1.id = 'f4'
     self.f1.f4 = f4_1
     f1.portal_url = URLTool()
     f1.refs = ReferenceCollection()
开发者ID:goschtl,项目名称:zope,代码行数:20,代码来源:testReferences.py

示例10: testReplace

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
 def testReplace(self):
     old_f = Folder()
     old_f.id = 'item'
     inner_f = HBTreeFolder2('inner')
     old_f._setObject(inner_f.id, inner_f)
     self.ff._populateFromFolder(old_f)
     self.assertEqual(self.ff.objectCount(), 1)
     self.assert_(self.ff.has_key('inner'))
     self.assertEqual(self.getBase(self.ff._getOb('inner')), inner_f)
开发者ID:alvsgithub,项目名称:erp5,代码行数:11,代码来源:testHBTreeFolder2.py

示例11: createTileContainer

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def createTileContainer(self, tileContainerName=None):
        """ create a container for the next group of tiles within the data container """

        if hasattr(self._v_saveFolderObject, tileContainerName):
            # allow for tiles to be updated from a changed image
            self._v_saveFolderObject._delObject(tileContainerName)
        if not hasattr(self._v_saveFolderObject, tileContainerName):
            newFolder = Folder()
            newFolder.id = tileContainerName
            self._v_saveFolderObject._setObject(tileContainerName, newFolder)
        transaction.savepoint()
        return
开发者ID:jerome-nexedi,项目名称:erp5,代码行数:14,代码来源:ERP5ZoomifyImage.py

示例12: testObjectIdsWithMetaType

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
 def testObjectIdsWithMetaType(self):
     f2 = Folder()
     f2.id = 'subfolder'
     self.f._setOb(f2.id, f2)
     mt1 = self.ff.meta_type
     mt2 = Folder.meta_type
     self.assertEqual(list(self.f.objectIds(mt1)), ['item'])
     self.assertEqual(list(self.f.objectIds((mt1, ))), ['item'])
     self.assertEqual(list(self.f.objectIds(mt2)), ['subfolder'])
     lst = list(self.f.objectIds([mt1, mt2]))
     lst.sort()
     self.assertEqual(lst, ['item', 'subfolder'])
     self.assertEqual(list(self.f.objectIds('blah')), [])
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:15,代码来源:testBTreeFolder2.py

示例13: testObjectIdsWithMetaType

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
 def testObjectIdsWithMetaType(self):
     f2 = Folder()
     f2.id = "subfolder"
     self.f._setOb(f2.id, f2)
     mt1 = self.ff.meta_type
     mt2 = Folder.meta_type
     self.assertEqual(list(self.f.objectIds(mt1)), ["item"])
     self.assertEqual(list(self.f.objectIds((mt1,))), ["item"])
     self.assertEqual(list(self.f.objectIds(mt2)), ["subfolder"])
     lst = list(self.f.objectIds([mt1, mt2]))
     lst.sort()
     self.assertEqual(lst, ["item", "subfolder"])
     self.assertEqual(list(self.f.objectIds("blah")), [])
开发者ID:eaudeweb,项目名称:naaya,代码行数:15,代码来源:testBTreeFolder2.py

示例14: createDataContainer

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def createDataContainer(self):
        """ create a folder that contains all the tiles of the image """

        self._v_saveToLocation = str(self._v_imageObject.getId()) + "_data"
        parent = self._v_imageObject.aq_parent
        if hasattr(parent, self._v_saveToLocation):
            # allow for tiles to be updated from a changed image
            parent._delObject(self._v_saveToLocation)
        if not hasattr(parent, self._v_saveToLocation):
            newFolder = Folder()
            newFolder.id = self._v_saveToLocation
            parent._setObject(self._v_saveToLocation, newFolder)
        self._v_saveFolderObject = parent[self._v_saveToLocation]
        transaction.savepoint()
        return
开发者ID:jerome-nexedi,项目名称:erp5,代码行数:17,代码来源:ERP5ZoomifyImage.py

示例15: _createZODBClone

# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import id [as 别名]
    def _createZODBClone(self):
        """Create a ZODB (editable) equivalent of this object."""
        # Create a Folder to hold the properties.
        obj = Folder()
        obj.id = self.getId()
        map = []
        for p in self._properties:
            # This should be secure since the properties come
            # from the filesystem.
            setattr(obj, p['id'], getattr(self, p['id']))
            map.append({'id': p['id'],
                        'type': p['type'],
                        'mode': 'wd',})
        obj._properties = tuple(map)

        return obj
开发者ID:groupserver,项目名称:Products.DataTemplates,代码行数:18,代码来源:FSNewPropertiesObject.py


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