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


Python Folder.manage_addFolder函数代码示例

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


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

示例1: afterSetUp

    def afterSetUp(self):
        """ Adding an OAIServer, a ZCatalog and a ZCatalogHarvester

        """
        manage_addZCatalog(self.app, 'catalog', 'Catalog')
        manage_addOAIServer(self.app, 'oai', title=u'OAI Server')

        manage_addFolder(self.app, 'folder', 'Folder')
        self.app.folder.description = u'Some descr'

        manage_addFolder(self.app, 'folder1', 'Folder1')
        self.app.folder1.description = u'Some descr111'

        self.app.catalog.catalog_object(self.app.folder,
                                        self.app.folder.absolute_url(1))
        self.app.catalog.catalog_object(self.app.folder1,
                                        self.app.folder1.absolute_url(1))

        manage_addZCatalogHarvester(self.app.oai, 'harvester',
                                    title=u'Harvester',
                                    search_meta_types=Folder.meta_type)

        self.server = startZServer()
        self.server_url = 'http://%s:%s/' % (self.server[0],
                                             str(self.server[1]))
开发者ID:eaudeweb,项目名称:naaya,代码行数:25,代码来源:test_OAIAggregatorFunctional.py

示例2: _initFolders

    def _initFolders(self):

        self.connection = makeConnection()
        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            responseOut = self.responseOut = cStringIO.StringIO()
            self.app = makerequest( self.root, stdout=responseOut )
            manage_addFolder( self.app, 'folder1' )
            manage_addFolder( self.app, 'folder2' )
            folder1 = getattr( self.app, 'folder1' )
            folder2 = getattr( self.app, 'folder2' )

            manage_addFile( folder1, 'file'
                          , file='', content_type='text/plain')

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            transaction.commit()
        except:
            self.connection.close()
            raise
        transaction.begin()

        return self.app._getOb( 'folder1' ), self.app._getOb( 'folder2' )
开发者ID:wpjunior,项目名称:proled,代码行数:28,代码来源:testCopySupport.py

示例3: installUi

 def installUi(self):
     '''Installs the user interface.'''
     # Some useful imports
     from OFS.Folder import manage_addFolder
     from OFS.Image import manage_addImage, manage_addFile
     from Products.PythonScripts.PythonScript import PythonScript
     from Products.PageTemplates.ZopePageTemplate import \
          manage_addPageTemplate
     # Delete the existing folder if it existed.
     zopeContent = self.app.objectIds()
     if 'ui' in zopeContent: self.app.manage_delObjects(['ui'])
     manage_addFolder(self.app, 'ui')
     # Browse the physical ui folders (the Appy one and an app-specific, if
     # the app defines one) and create the corresponding objects in the Zope
     # folder. In the case of files having the same name in both folders,
     # the one from the app-specific folder is chosen.
     j = os.path.join
     uiFolders = [j(j(appy.getPath(), 'gen'), 'ui')]
     appUi = j(self.config.diskFolder, 'ui')
     if os.path.exists(appUi): uiFolders.insert(0, appUi)
     for ui in uiFolders:
         for root, dirs, files in os.walk(ui):
             folderName = root[len(ui):]
             # Get the Zope folder that corresponds to this name
             zopeFolder = self.app.ui
             if folderName:
                 for name in folderName.strip(os.sep).split(os.sep):
                     zopeFolder = zopeFolder._getOb(name)
             # Create sub-folders at this level
             for name in dirs:
                 if not hasattr(zopeFolder.aq_base, name):
                     manage_addFolder(zopeFolder, name)
             # Create files at this level
             for name in files:
                 zopeName, ext = os.path.splitext(name)
                 if ext not in ('.pt', '.py'):
                     # In the ZODB, pages and scripts have their name without
                     # their extension.
                     zopeName = name
                 if hasattr(zopeFolder.aq_base, zopeName): continue
                 f = file(j(root, name))
                 if ext in gen.File.imageExts:
                     manage_addImage(zopeFolder, zopeName, f)
                 elif ext == '.pt':
                     manage_addPageTemplate(zopeFolder,zopeName,'',f.read())
                 elif ext == '.py':
                     obj = PythonScript(zopeName)
                     zopeFolder._setObject(zopeName, obj)
                     zopeFolder._getOb(zopeName).write(f.read())
                 else:
                     manage_addFile(zopeFolder, zopeName, f)
                 f.close()
     # Update the home page
     if 'index_html' in zopeContent:
         self.app.manage_delObjects(['index_html'])
     manage_addPageTemplate(self.app, 'index_html', '', homePage)
     # Update the error page
     if 'standard_error_message' in zopeContent:
         self.app.manage_delObjects(['standard_error_message'])
     manage_addPageTemplate(self.app, 'standard_error_message', '',errorPage)
开发者ID:a-iv,项目名称:appy,代码行数:60,代码来源:installer.py

示例4: setUp

    def setUp(self):
        self.responseOut = cStringIO.StringIO()
        self.connection = makeConnection()
        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            self.app = makerequest(self.root, stdout=self.responseOut)
            try: self.app._delObject(TESTFOLDER_NAME)
            except AttributeError: pass
            manage_addFolder(self.app, TESTFOLDER_NAME)
            folder = getattr( self.app, TESTFOLDER_NAME )

            data = string.letters
            manage_addFile( folder, 'file'
                          , file=data, content_type='text/plain')

            self.file = folder.file
            self.data = data

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            transaction.commit()
        except:
            self.connection.close()
            raise
开发者ID:wpjunior,项目名称:proled,代码行数:28,代码来源:testRanges.py

示例5: testNextPreviousItems

    def testNextPreviousItems(self):
        container = self.portal[self.portal.invokeFactory(self._portal_type, 'case3')]
        for id in range(1, 4):
            container.invokeFactory('Document', 'subDoc%d' % id)

        from OFS.Folder import manage_addFolder
        manage_addFolder(container, 'notacontentishtype')

        for id in range(5, 6):
            container.invokeFactory('Document', 'subDoc%d' % id)

        adapter = INextPreviousProvider(container)
        # text data for next/previous items
        next = adapter.getNextItem(container.subDoc2)
        self.assertEqual(next['id'], 'subDoc3')
        self.assertEqual(next['portal_type'], 'Document')
        self.assertEqual(next['url'], container.subDoc3.absolute_url())
        previous = adapter.getPreviousItem(container.subDoc2)
        self.assertEqual(previous['id'], 'subDoc1')
        self.assertEqual(previous['portal_type'], 'Document')
        self.assertEqual(previous['url'], container.subDoc1.absolute_url())

        # #11234 not contentish contents shouldn't be returned
        # as next or previous content
        next = adapter.getNextItem(container.subDoc3)
        self.assertEqual(next['id'], 'subDoc5')
        previous = adapter.getPreviousItem(container.subDoc5)
        self.assertEqual(previous['id'], 'subDoc3')

        # first item should not have a previous item
        previous = adapter.getPreviousItem(container.subDoc1)
        self.assertEqual(previous, None)
        # last item should not have a next item
        next = adapter.getNextItem(container.subDoc5)
        self.assertEqual(next, None)
开发者ID:bogdangi,项目名称:plone.app.dexterity,代码行数:35,代码来源:test_nextprevious.py

示例6: test_zcatalog

    def test_zcatalog(self):
        """ Using the ZCatalog storage
        Test flow:

        Add an OAIHarvester with the local URL of the OAIServer ->
        update it against and check the presence of the OAIRecords.

        Add one folder -> update the OAIServer -> update OAIAggregator ->
        update the specific OAIHarvester and recheck it there is a new OAIRecord
        in the OAIHarvester

        Same ideea after deleting the folder that was added.

        """
        manage_addOAIAggregator(self.app, 'oai_agg', title=u"OAI Aggregator",
                                storage='ZCatalog')
        manage_addOAIHarvester(self.app.oai_agg, 'oai_harv',
                               title=u"Local OAI Server",
                               url=self.server_url + 'oai')
        self.app.oai_agg.update()
        # Has 2 records in it's contents
        self.assertEqual(len(self.app.oai_agg.oai_harv.\
                             objectValues([OAIRecord.meta_type])), 2)

        #Search catalog
        catalog = self.app.oai_agg.getCatalog()
        results = catalog.searchResults(meta_type=OAIRecord.meta_type)
        self.assertEqual(len(results), 2)

        #Adding one folder and repeat the procedure
        manage_addFolder(self.app, 'other_folder', 'Some other folder')
        self.app.other_folder.description = u'This is some kind of description'
        self.app.catalog.catalog_object(self.app.other_folder,
                                        self.app.other_folder.absolute_url(1))
        self.app.oai.harvester.update(True) #Update forced

        #Update the aggregator once again
        self.app.oai_agg.update()

        # Has 2 records in it's contents because the harvester can be updated
        # only after a day
        self.assertEqual(len(self.app.oai_agg.oai_harv.\
                             objectValues([OAIRecord.meta_type])), 2)

        #We need to do an manual update of the harvester
        self.app.oai_agg.oai_harv.update()
        self.assertEqual(len(self.app.oai_agg.oai_harv.\
                             objectValues([OAIRecord.meta_type])), 3)

        self.app.catalog.uncatalog_object(
            self.app.other_folder.absolute_url(1))
        self.app.manage_delObjects(['other_folder'])

        #Updating ZCatalogHarvester
        self.app.oai.harvester.update(True) #Update forced

        #updating OAIHarvester
        self.app.oai_agg.oai_harv.update()
        self.assertEqual(len(self.app.oai_agg.oai_harv.\
                             objectValues([OAIRecord.meta_type])), 2)
开发者ID:eaudeweb,项目名称:naaya,代码行数:60,代码来源:test_OAIAggregatorFunctional.py

示例7: _setupFolder

 def _setupFolder(self):
     '''Creates and configures the folder.'''
     from OFS.Folder import manage_addFolder
     manage_addFolder(self.app, folder_name)
     self.folder = getattr(self.app, folder_name)
     self.folder._addRole(user_role)
     self.folder.manage_role(user_role, standard_permissions)
开发者ID:dhavlik,项目名称:Zope,代码行数:7,代码来源:ZopeTestCase.py

示例8: installUi

 def installUi(self):
     '''Installs the user interface'''
     # Some useful imports
     from OFS.Folder import manage_addFolder
     from OFS.Image import manage_addImage, manage_addFile
     # Delete the existing folder if it existed
     zopeContent = self.app.objectIds()
     for name in ('ui', self.favIcon):
         if name in zopeContent: self.app.manage_delObjects([name])
     manage_addFolder(self.app, 'ui')
     # Browse the physical ui folders (the Appy one and an app-specific, if
     # the app defines one) and create the corresponding objects in the Zope
     # folder. In the case of files having the same name in both folders,
     # the one from the app-specific folder is chosen.
     j = os.path.join
     uiFolders = [j(j(appy.getPath(), 'gen'), 'ui')]
     for uiFolder in self.config.appConfig.uiFolders:
         if uiFolder.startswith('..'):
             folder = j(os.path.dirname(self.config.diskFolder),uiFolder[3:])
         else:
             folder = j(self.config.diskFolder, uiFolder)
         if os.path.exists(folder):
             uiFolders.insert(0, folder)
     for ui in uiFolders:
         for root, dirs, files in os.walk(ui):
             folderName = root[len(ui):]
             # Get the Zope folder that corresponds to this name
             zopeFolder = self.app.ui
             if folderName:
                 for name in folderName.strip(os.sep).split(os.sep):
                     zopeFolder = zopeFolder._getOb(name)
             # Create sub-folders at this level
             for name in dirs:
                 if not hasattr(zopeFolder.aq_base, name):
                     manage_addFolder(zopeFolder, name)
             # Create files at this level
             for name in files:
                 ext = os.path.splitext(name)[1]
                 if hasattr(zopeFolder.aq_base, name): continue
                 f = file(j(root, name))
                 if name == self.favIcon:
                     if not hasattr(self.app, name):
                         # Copy it at the root. Else, IE won't notice it.
                         manage_addImage(self.app, name, f)
                 elif ext in gen.File.imageExts:
                     manage_addImage(zopeFolder, name, f)
                 else:
                     manage_addFile(zopeFolder, name, f)
                 f.close()
     # Update home and error pages
     from Products.PageTemplates.ZopePageTemplate import \
          manage_addPageTemplate
     if 'index_html' in zopeContent:
         self.app.manage_delObjects(['index_html'])
     manage_addPageTemplate(self.app, 'index_html', '', homePage)
     if 'standard_error_message' in zopeContent:
         self.app.manage_delObjects(['standard_error_message'])
     manage_addPageTemplate(self.app, 'standard_error_message', '',
                            errorPage)
开发者ID:tonibagur,项目名称:appy,代码行数:59,代码来源:installer.py

示例9: initPackage

def initPackage(context):
    site = api.portal.get()
    if not 'replication_connections' in site.keys():
        manage_addFolder(
            site,
            id='replication_connections',
            title='Database Connections for Plomino Replication',
        )
开发者ID:gisweb,项目名称:plomino.replication,代码行数:8,代码来源:setuphandlers.py

示例10: _get_slider_images_folder

 def _get_slider_images_folder(self):
     layout_tool = self.getLayoutTool()
     # not using get_current_skin to make it work for CHMBE
     skin = layout_tool._getOb(layout_tool.getCurrentSkinId())
     # add images folder if it doesn't exist
     if not skin.hasObject('slider-images'):
         manage_addFolder(skin, 'slider-images')
     return skin._getOb('slider-images')
开发者ID:eaudeweb,项目名称:naaya.chm,代码行数:8,代码来源:CHMSite.py

示例11: manage_addXWFMailingList

def manage_addXWFMailingList(self, id, mailto, title='Mailing List',
                             REQUEST=None):
    """ Add an XWFMailingList to a container."""
    ob = XWFMailingList(id, title, mailto)
    self._setObject(id, ob)
    ob = getattr(self, id)
    ob.init_properties()
    manage_addFolder(ob, b'archive', 'mailing list archives')

    if REQUEST is not None:
        return self.manage_main(self, REQUEST)
开发者ID:groupserver,项目名称:Products.XWFMailingListManager,代码行数:11,代码来源:XWFMailingList.py

示例12: setUp

    def setUp( self ):
        import cStringIO
        import transaction
        from AccessControl import SecurityManager
        from AccessControl.SecurityManagement import newSecurityManager
        from OFS.Application import Application
        from OFS.Folder import manage_addFolder
        from OFS.Image import manage_addFile
        from Testing.makerequest import makerequest
        from ZODB.DB import DB
        from ZODB.DemoStorage import DemoStorage

        s = DemoStorage()
        self.connection = DB(s).open()

        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            responseOut = self.responseOut = cStringIO.StringIO()
            self.app = makerequest( self.root, stdout=responseOut )
            manage_addFolder( self.app, 'folder1' )
            folder1 = getattr( self.app, 'folder1' )
            setattr(folder1, '+something', 'plus')

            folder1.all_meta_types = \
                                    ({ 'name'        : 'File'
                                     , 'action'      : 'manage_addFile'
                                     , 'permission'  : 'Add images and files'
                                     }
                                    ,
                                    )

            manage_addFile( folder1, 'file'
                          , file='', content_type='text/plain')

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            transaction.commit()
        except:
            self.connection.close()
            raise
        transaction.begin()
        self.folder1 = getattr( self.app, 'folder1' )

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
        newSecurityManager( None, self._makeUser().__of__( self.root ) )
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:50,代码来源:testTraverse.py

示例13: test_category_object

    def test_category_object(self):
        # Permissions for action category 'object*' should be
        # evaluated in object context.
        manage_addFolder(self.site, 'actions_dummy')
        self.object = self.site.actions_dummy
        self.object.manage_permission('View', [], acquire=0)

        WANTED = {'allowed': False, 'category': 'object'}

        action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
        ec = createExprContext(self.site, self.site, self.object)
        ai = self._makeOne(action, ec)

        self.assertEqual( ai['category'], WANTED['category'] )
        self.assertEqual( ai['allowed'], WANTED['allowed'] )
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:15,代码来源:test_ActionInformation.py

示例14: installBaseObjects

    def installBaseObjects(self):
        '''Creates the tool and the base data folder if they do not exist.'''
        # Create the tool.
        zopeContent = self.app.objectIds()
        from OFS.Folder import manage_addFolder

        if 'config' not in zopeContent:
            toolName = '%sTool' % self.productName
            gutils.createObject(self.app, 'config', toolName, self.productName,
                                wf=False, noSecurity=True)
        # Create the base data folder.
        if 'data' not in zopeContent: manage_addFolder(self.app, 'data')

        # Remove some default objects created by Zope but not useful to Appy
        for name in ('standard_html_footer', 'standard_html_header',\
                     'standard_template.pt'):
            if name in zopeContent: self.app.manage_delObjects([name])
开发者ID:tonibagur,项目名称:appy,代码行数:17,代码来源:installer.py

示例15: initialize

def initialize(context):
    """ """
    app = context._ProductContext__app

    context.registerClass(
            CronTool,
            permission=PERMISSION_ADD_CRON_TOOL,
            constructors=CronTool._constructors
    )

    if app._getOb('naaya_admin_tool', None) is None:
        manage_addFolder(app, 'naaya_admin_tool', title='Naaya Admin Tool')
        LOG('NaayaAdminTool', INFO, 'naaya_admin_tool folder created')
    naaya_admin_tool = app._getOb('naaya_admin_tool')

    configure_catalog(app)
    configure_cron(naaya_admin_tool)
开发者ID:eaudeweb,项目名称:naaya,代码行数:17,代码来源:__init__.py


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