plone.indexer和Dexterity的问题

编程入门 行业动态 更新时间:2024-10-21 11:44:49
本文介绍了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的问题

本文发布于:2023-07-17 03:32:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128988.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:plone   indexer   Dexterity

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!