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


Python Folder.Folder类代码示例

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


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

示例1: test_upo_state_after_deactivate

    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,代码行数:26,代码来源:zope2testbase.py

示例2: test_store

    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,代码行数:32,代码来源:zope2testbase.py

示例3: test_rename

    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,代码行数:29,代码来源:zope2testbase.py

示例4: test_btreefolder2

    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,代码行数:35,代码来源:zope2testbase.py

示例5: manage_addMounts

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,代码行数:33,代码来源:MountedObject.py

示例6: test_anyfolder_storage

    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,代码行数:31,代码来源:zope2testbase.py

示例7: test_OFS_ObjectManager__importObjectFromFile_xml

    def test_OFS_ObjectManager__importObjectFromFile_xml(self):
        from OFS.DTMLMethod import DTMLMethod
        from OFS.Folder import Folder
        from OFS.XMLExportImport import exportXML

        connection, app = self._makeJarAndRoot()
        dm = DTMLMethod('test')
        dm._setId('test')
        dm.munge(_LONG_DTML)
        app._setObject('test', dm)
        sub = Folder('sub')
        app._setObject('sub', sub)
        transaction.savepoint(optimistic=True) # need an OID!
        oid = dm._p_oid
        sub = app._getOb('sub')

        handle, path = tempfile.mkstemp(suffix='.xml')
        try:
            ostream = os.fdopen(handle,'wb')
            data = exportXML(connection, oid, ostream)
            ostream.close()
            sub._importObjectFromFile(path, 0, 0)
        finally:
            # if this operaiton fails with a 'Permission Denied' error,
            # then comment it out as it's probably masking a failure in
            # the block above.
            os.remove(path)
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:27,代码来源:test_XMLExportImport.py

示例8: test_exportXML

    def test_exportXML(self):
        from OFS.Folder import Folder
        from OFS.Image import Image
        from OFS.XMLExportImport import exportXML

        connection, app = self._makeJarAndRoot()
        data = open(imagedata, 'rb')

        sub = Folder('sub')
        app._setObject('sub', sub)
        img = Image('image', '', data, 'image/gif')
        sub._setObject('image', img)
        img._setProperty('prop1', 3.14159265359, 'float')
        img._setProperty('prop2', 1, 'int')
        img._setProperty('prop3', 2L**31-1, 'long')
        img._setProperty('prop4', 'xxx', 'string')
        img._setProperty('prop5', ['xxx', 'zzz'], 'lines')
        img._setProperty('prop6', u'xxx', 'unicode')
        img._setProperty('prop7', [u'xxx', u'zzz'], 'ulines')
        img._setProperty('prop8', '<&>', 'string')
        img._setProperty('prop9', u'<&>', 'unicode')
        img._setProperty('prop10', '<]]>', 'string')
        img._setProperty('prop11', u'<]]>', 'unicode')
        img._setProperty('prop12', u'£', 'unicode')
        transaction.savepoint(optimistic=True)
        oid = sub._p_oid

        handle, path = tempfile.mkstemp(suffix='.xml')
        try:
            ostream = os.fdopen(handle,'wb')
            data = exportXML(connection, oid, ostream)
            ostream.close()
        finally:
            os.remove(path)
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:34,代码来源:test_XMLExportImport.py

示例9: testGenerateIdDenialOfServicePrevention

 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,代码行数:7,代码来源:testBTreeFolder2.py

示例10: _makeRoot

    def _makeRoot( self ):

        from OFS.Folder import Folder
        root = Folder( 'root' )
        tt = DummyTypesTool()
        root._setObject( 'portal_types', tt )
        return root
开发者ID:goschtl,项目名称:zope,代码行数:7,代码来源:test_WorkflowTool.py

示例11: test_pruneMemberData

    def test_pruneMemberData(self):
        # This needs a tad more setup
        from OFS.Folder import Folder
        from ..MembershipTool import MembershipTool
        folder = Folder('test')
        folder._setObject('portal_memberdata', self._makeOne())
        sm = getSiteManager()
        sm.registerUtility(MembershipTool().__of__(folder), IMembershipTool)
        folder._setObject('acl_users', DummyUserFolder())
        tool = folder.portal_memberdata

        # Create some members
        for i in range(20):
            tool.registerMemberData('Dummy_%i' % i, 'user_foo_%i' % i)

        # None of these fake members are in the user folder, which means
        # there are 20 members and 20 "orphans"
        contents = tool.getMemberDataContents()
        info_dict = contents[0]
        self.assertEqual(info_dict['member_count'], 20)
        self.assertEqual(info_dict['orphan_count'], 20)

        # Calling the prune method should delete all orphans, so we end
        # up with no members in the tool.
        tool.pruneMemberDataContents()
        contents = tool.getMemberDataContents()
        info_dict = contents[0]
        self.assertEqual(info_dict['member_count'], 0)
        self.assertEqual(info_dict['orphan_count'], 0)
开发者ID:zopefoundation,项目名称:Products.CMFCore,代码行数:29,代码来源:test_MemberDataTool.py

示例12: test_forbidden_tools

    def test_forbidden_tools( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset
        TOOL_IDS = ( 'doomed', 'blasted', 'saved' )

        site = self._initSite()

        for tool_id in TOOL_IDS:
            pseudo = Folder()
            pseudo._setId( tool_id )
            site._setObject( tool_id, pseudo )

        self.assertEqual( len( site.objectIds() ), len( TOOL_IDS ) + 1 )

        for tool_id in TOOL_IDS:
            self.failUnless( tool_id in site.objectIds() )

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _FORBIDDEN_TOOLSET_XML

        importToolset( context )

        self.assertEqual( len( site.objectIds() ), 2 )
        self.failUnless( 'setup_tool' in site.objectIds() )
        self.failUnless( 'saved' in site.objectIds() )
开发者ID:dtgit,项目名称:dtedu,代码行数:26,代码来源:test_tool.py

示例13: test_required_tools_missing_acquired_nofail

    def test_required_tools_missing_acquired_nofail( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()
        parent_site = Folder()

        mandatory = AnotherDummyTool()
        mandatory._setId( 'mandatory' )
        parent_site._setObject( 'mandatory', mandatory )

        obligatory = AnotherDummyTool()
        obligatory._setId( 'obligatory' )
        parent_site._setObject( 'obligatory', obligatory )

        site = site.__of__(parent_site)

        # acquiring subobjects of a different class during import
        # should not prevent new objects from being created if they
        # don't exist in the site

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
                                   , DummyTool ) )

        self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
                                   , DummyTool ) )
开发者ID:dtgit,项目名称:dtedu,代码行数:34,代码来源:test_tool.py

示例14: __init__

 def __init__(self, *args, **kw):
     Folder.__init__(self, *args, **kw)
     SilvaService.__init__(self, *args, **kw)
     self._config_declarations = {}
     self._per_tag_allowed_attr = set(DEFAULT_PER_TAG_WHITELISTS)
     self._allowed_html_attributes = set(DEFAULT_HTML_ATTR_WHITELIST)
     self._allowed_css_attributes = set(DEFAULT_CSS_PROP_WHITELIST)
开发者ID:silvacms,项目名称:silva.core.editor,代码行数:7,代码来源:service.py

示例15: test_foreign_line_endings

 def test_foreign_line_endings(self):
     # Load the various line ending files and get their output
     container = Folder("container_for_execution")
     for fformat in ("unix", "dos", "mac"):
         container._setObject(fformat, self._makeOne(fformat, "test_%s.py" % fformat))
         script = getattr(container, fformat)
         self.assertEqual(script(), fformat)
开发者ID:pigaov10,项目名称:plone4.3,代码行数:7,代码来源:test_FSPythonScript.py


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