indexing - plone.indexer 和 Dexterity 的问题

标签 indexing plone dexterity

我希望为基于 Dexterity 的自定义内容类型的属性(“扇区”)启用一个名为“扇区”的特殊索引。

在我的架构中,在 types/mycontent.py 中,我有:

class IMyContent(form.Schema):
    """
    My Content
    """
    sectors = schema.Set(
            title=_(u"Sectors"),
            description=_(u"Select some sectors"),
            value_type=schema.Choice(vocabulary=vocs.sectors),
            required=True,
        )

    (...)

然后我在 indexers.py 中以这种方式定义索引

from plone.indexer.decorator import indexer
from zr.content.types.mycontent import IMyContent

@indexer(IMyContent)
def Sectors(obj):
    """Indexer for Sectors attribute.
    """
    d = getattr(obj, "sectors", u"")
    return d if d else None

最后在根包configure.zcml中:

<adapter name="Sectors" factory=".indexers.Sectors"/>

但是,似乎不起作用。即使重新安装产品后,我也没有在portal_catalog 中看到索引,并且目录大脑对象似乎也没有它。

我做错了什么?

最佳答案

您没有定义目录索引。这只会使索引器可供添加。您的 GenericSetup 配置文件中需要一个具有以下内容的 Catalog.xml:

<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
 <index name="Sectors" meta_type="KeywordIndex">
  <indexed_attr value="Sectors"/>
 </index>
</object>

关于indexing - plone.indexer 和 Dexterity 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6651174/

相关文章:

sql-server - 当 WHERE 子句包含参数化值时,为什么 SQL Server 使用索引扫描而不是索引查找

python - 查找大于 x 的元素的索引

plone - 识别 Plone BlobStorage 中的文件

plone - 不带 Plone 体的变形器

python - 我如何在敏捷类型中订购行为 IDublinCore?

database - 是否值得索引 day_of_week 列?

workflow - Plone 人 4 : restricting published content

Plone/dexterity - 在事件中,如何更改只有所有者拥有查看权限的内容类型对象的所有权角色?

python - 为 plone 4 实现一个简单的灵活性内容类型

grails - 东方数据库:无法创建索引