本文整理汇总了Python中Products.CMFCore.CatalogTool.CatalogTool.addIndex方法的典型用法代码示例。如果您正苦于以下问题:Python CatalogTool.addIndex方法的具体用法?Python CatalogTool.addIndex怎么用?Python CatalogTool.addIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFCore.CatalogTool.CatalogTool
的用法示例。
在下文中一共展示了CatalogTool.addIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _initSite
# 需要导入模块: from Products.CMFCore.CatalogTool import CatalogTool [as 别名]
# 或者: from Products.CMFCore.CatalogTool.CatalogTool import addIndex [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
示例2: UniqueIdHandlerTests
# 需要导入模块: from Products.CMFCore.CatalogTool import CatalogTool [as 别名]
# 或者: from Products.CMFCore.CatalogTool.CatalogTool import addIndex [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):
#.........这里部分代码省略.........