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


Python CatalogTool.addColumn方法代码示例

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


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

示例1: _initSite

# 需要导入模块: from Products.CMFCore.CatalogTool import CatalogTool [as 别名]
# 或者: from Products.CMFCore.CatalogTool.CatalogTool import addColumn [as 别名]
    def _initSite(self, foo=2):
        site = Folder(id='site').__of__(self.app)
        ctool = CatalogTool()
        getSiteManager().registerUtility(ctool, ICatalogTool)

        for obj_id in ctool.objectIds():
            ctool._delObject(obj_id)
        for idx_id in ctool.indexes():
            ctool.delIndex(idx_id)
        for col in ctool.schema()[:]:
            ctool.delColumn(col)

        if foo > 0:
            ctool._setObject('foo_plexicon', PLexicon('foo_plexicon'))
            lex = ctool.foo_plexicon
            lex._pipeline = (Splitter(), CaseNormalizer(), StopWordRemover())

            extra = _extra()
            extra.lexicon_id = 'foo_plexicon'
            extra.index_type = 'Okapi BM25 Rank'
            ctool.addIndex('foo_zctext', 'ZCTextIndex', extra)

            ctool.addColumn('foo_zctext')

        return site, ctool
开发者ID:goschtl,项目名称:zope,代码行数:27,代码来源:test_catalog.py

示例2: test_itemCataloguing

# 需要导入模块: from Products.CMFCore.CatalogTool import CatalogTool [as 别名]
# 或者: from Products.CMFCore.CatalogTool.CatalogTool import addColumn [as 别名]
    def test_itemCataloguing(self):
        ctool = CatalogTool()
        ctool.addColumn('in_reply_to')
        getSiteManager().registerUtility(ctool, ICatalogTool)
        dtool = self.dtool
        test = self._makeDummyContent('test', catalog=1)
        test.allow_discussion = 1

        self.assertEqual( len(ctool), 1 )
        self.failUnless(has_path(ctool, test.getPhysicalPath()))
        talkback = dtool.getDiscussionFor(test)
        self.assertEqual( talkback.getPhysicalPath(),
                          ('', 'bar', 'site', 'test', 'talkback') )
        talkback.createReply( title='test'
                            , text='blah'
                            )
        self.assertEqual( len(ctool), 2 )
        for reply in talkback.getReplies():
            self.failUnless(has_path(ctool, reply.getPhysicalPath()))
            self.failUnless(has_path(ctool, '/bar/site/test/talkback/%s'
                                            % reply.getId()))

        reply1 = talkback.getReplies()[0]
        path1 = '/'.join(reply1.getPhysicalPath())
        self.assertEqual( ctool.getMetadataForUID(path1),
                          {'in_reply_to': None} )

        talkback1 = dtool.getDiscussionFor(reply1)
        talkback1.createReply( title='test2'
                             , text='blah2'
                             )
        for reply in talkback.getReplies():
            self.failUnless(has_path(ctool, reply.getPhysicalPath()))
            self.failUnless(has_path(ctool, '/bar/site/test/talkback/%s'
                                            % reply.getId()))
        for reply in talkback1.getReplies():
            self.failUnless(has_path(ctool, reply.getPhysicalPath()))
            self.failUnless(has_path(ctool, '/bar/site/test/talkback/%s'
                                            % reply.getId()))

        reply2 = talkback1.getReplies()[0]
        path2 = '/'.join(reply2.getPhysicalPath())
        self.assertEqual( ctool.getMetadataForUID(path2),
                          {'in_reply_to': reply1.getId()} )
开发者ID:goschtl,项目名称:zope,代码行数:46,代码来源:test_Discussions.py

示例3: UniqueIdHandlerTests

# 需要导入模块: from Products.CMFCore.CatalogTool import CatalogTool [as 别名]
# 或者: from Products.CMFCore.CatalogTool.CatalogTool import addColumn [as 别名]
class UniqueIdHandlerTests(SecurityTest):

    def _getTargetClass(self):
        from Products.CMFUid.UniqueIdHandlerTool import UniqueIdHandlerTool

        return UniqueIdHandlerTool

    def _makeOne(self, *args, **kw):
        return self._getTargetClass()(*args, **kw)

    def setUp(self):
        from Products.CMFCore.CatalogTool import CatalogTool
        from Products.CMFUid.interfaces import IUniqueIdHandler
        from Products.CMFUid.UniqueIdAnnotationTool \
                import UniqueIdAnnotationTool
        from Products.CMFUid.UniqueIdGeneratorTool \
                import UniqueIdGeneratorTool

        SecurityTest.setUp(self)
        self.app._setObject('dummy', DummyContent(id='dummy'))
        self.app._setObject('dummy2', DummyContent(id='dummy2'))
        self.ctool = CatalogTool().__of__(self.app)
        self.uidhandler = self._makeOne()
        sm = getSiteManager()
        sm.registerUtility(self.ctool, ICatalogTool)
        sm.registerUtility(self.uidhandler, IUniqueIdHandler)
        sm.registerUtility(UniqueIdAnnotationTool(),
                           IUniqueIdAnnotationManagement)
        sm.registerUtility(UniqueIdGeneratorTool(), IUniqueIdGenerator)

        # Make sure we have our indices/columns
        uid_name = self.uidhandler.UID_ATTRIBUTE_NAME
        self.ctool.addIndex(uid_name, 'FieldIndex')
        self.ctool.addColumn(uid_name)

    def tearDown(self):
        cleanUp()
        SecurityTest.tearDown(self)

    def test_interfaces(self):
        from Products.CMFUid.interfaces import IUniqueIdBrainQuery
        from Products.CMFUid.interfaces import IUniqueIdHandler
        from Products.CMFUid.interfaces import IUniqueIdUnrestrictedQuery

        verifyClass(IUniqueIdBrainQuery, self._getTargetClass())
        verifyClass(IUniqueIdHandler, self._getTargetClass())
        verifyClass(IUniqueIdUnrestrictedQuery, self._getTargetClass())

    def test_getUidOfNotYetRegisteredObject(self):
        handler = self.uidhandler
        dummy = self.app.dummy
        UniqueIdError = handler.UniqueIdError

        self.assertEqual(handler.queryUid(dummy, None), None)
        self.assertRaises(UniqueIdError, handler.getUid, dummy)

    def test_getInvalidUid(self):
        handler = self.uidhandler
        dummy = self.app.dummy
        UniqueIdError = handler.UniqueIdError

        self.assertEqual(handler.queryObject(100, None), None)
        self.assertRaises(UniqueIdError, handler.getObject, 100)
        self.assertEqual(handler.unrestrictedQueryObject(100, None), None)
        self.assertRaises(UniqueIdError, handler.unrestrictedGetObject, 100)

        uid = handler.register(dummy)
        self.assertEqual(handler.queryObject(uid + 1, None), None)
        self.assertRaises(UniqueIdError, handler.getObject, uid + 1)
        self.assertEqual(handler.unrestrictedQueryObject(uid + 1, None), None)
        self.assertRaises(UniqueIdError, handler.unrestrictedGetObject, uid + 1)

    def test_getUidOfRegisteredObject(self):
        handler = self.uidhandler
        dummy = self.app.dummy

        uid = handler.register(dummy)
        self.assertEqual(handler.getUid(dummy), uid)

    def test_getRegisteredObjectByUid(self):
        handler = self.uidhandler
        dummy = self.app.dummy

        uid = handler.register(dummy)
        self.assertEqual(handler.getObject(uid), dummy)
        self.assertEqual(handler.unrestrictedGetObject(uid), dummy)

    def test_getUnregisteredObject(self):
        handler = self.uidhandler
        dummy = self.app.dummy
        UniqueIdError = handler.UniqueIdError

        uid = handler.register(dummy)
        handler.unregister(dummy)
        self.assertEqual(handler.queryObject(uid, None), None)
        self.assertRaises(UniqueIdError, handler.getObject, uid)
        self.assertEqual(handler.unrestrictedQueryObject(uid, None), None)
        self.assertRaises(UniqueIdError, handler.unrestrictedGetObject, uid)

    def test_getUidOfUnregisteredObject(self):
#.........这里部分代码省略.........
开发者ID:goschtl,项目名称:zope,代码行数:103,代码来源:test_uidhandling.py


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