plone.indexer和Dexterity的问题 [英] Problem with plone.indexer and Dexterity

查看:196
本文介绍了plone.indexer和Dexterity的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wish to enable a special index, called Sectors, for a attribute ('sectors') of my Dexterity based custom content-type.

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

In my schema, inside types/mycontent.py I have:

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

I then define the index in this way, inside 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和目录脑对象中的索引似乎也没有。

However, it does not seem to work. Even after reinstalling the product, I don't see the index in portal_catalog and catalog brain object do not seem to have it either.

我做错了什么?

推荐答案

您没有定义目录索引。这只会使索引器可用。您需要GenericSetup配置文件中的catalog.xml:

You aren't defining the catalogue index. This will just make the indexer available to be added. You require a catalog.xml in your GenericSetup profile with:

<?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>

这篇关于plone.indexer和Dexterity的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆