开发者

Custom SearchableText and HTML fields in Plone

开发者 https://www.devze.com 2023-03-26 07:41 出处:网络
I am writing a Dexterity content type which contains plain text and HTML fields. I want to have a custom Se开发者_开发知识库archableText() method which exposes these fields to portal_catalog and Plone

I am writing a Dexterity content type which contains plain text and HTML fields. I want to have a custom Se开发者_开发知识库archableText() method which exposes these fields to portal_catalog and Plone full text search.

I assume for plain text I can just do string join with spaces. But how I should preprocess HTML content when exposing it in SearchableText()?


for converting data in plone there is a tool called portal_transforms, which is quite intelligent in converting stuff (depending on your os / installation it may also be able to convert .doc, .pdf etc.):

from Products.CMFCore.utils import getToolByName
transforms = getToolByName(self.context, 'portal_transforms')
stream = transforms.convertTo('text/plain', html, mimetype='text/html')
text = stream.getData().strip()

for indexing fields in dexterity I propose to use collective.dexteritytextindexer (but there is no TTW support at the moment). -> http://pypi.python.org/pypi/collective.dexteritytextindexer -> https://github.com/collective/collective.dexteritytextindexer

cheers


Maybe collective.dexteritytextindexer can help you to get part of what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消