将计算的元数据添加到敏捷对象的目录中(plone 4)

发布于 2024-12-19 11:27:07 字数 1454 浏览 1 评论 0原文

我想使用计算字符串创建目录元数据。因此,遵循 Aspeli 的书开发人员手册 我继续创建索引器:

# indexer.py
@grok.adapter(Entry, name='bind_representation')
@indexer(Entry)
def bindIndexer(context):
    print str(IBindRepresentable(context))
    return str(IBindRepresentable(context))

并使用genericSetup:

<!-- profiles/default/catalog.xml -->
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">

  <index name="bind_representation" meta_type="ZCTextIndex">
                  <!-- I tried with meta_type="FieldIndex" too -->
    <indexed_attr value="bind_representation"/>

    <!-- copied from other text metadata -->
    <extra name="index_type" value="Okapi BM25 Rank"/>
    <extra name="lexicon_id" value="plaintext_lexicon"/>
  </index>
</object>

问题是:(1)仅注册索引,而不注册元数据,以及(2)在重新索引所有 zodb 后,bind_representation 仍然找不到任何索引条目,即使它们存在。

引用的示例仅处理预先存在的索引,因此我不确定catalog.xml 的内容。 bindIndexer 似乎根本没有被调用,因为它的打印语句从未被执行。我也将 bindIndexer 复制到entry.py,以确保它没有被忽略,但仍然没有任何结果。

我缺少什么?

谢谢。

I want to create a catalog metadata with a computed string. So following Aspeli's book and the developer manual I proceeded to create an indexer:

# indexer.py
@grok.adapter(Entry, name='bind_representation')
@indexer(Entry)
def bindIndexer(context):
    print str(IBindRepresentable(context))
    return str(IBindRepresentable(context))

and register the index with genericSetup:

<!-- profiles/default/catalog.xml -->
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">

  <index name="bind_representation" meta_type="ZCTextIndex">
                  <!-- I tried with meta_type="FieldIndex" too -->
    <indexed_attr value="bind_representation"/>

    <!-- copied from other text metadata -->
    <extra name="index_type" value="Okapi BM25 Rank"/>
    <extra name="lexicon_id" value="plaintext_lexicon"/>
  </index>
</object>

The problems are: (1) only the index is registered, not the metadata, and (2) After reindex all the zodb, bind_representation still doesn't find any entry to index, even when they are.

The examples cited only deal with pre-existent indexes, so I'm not sure about the content of catalog.xml. bindIndexer seems not to be called at all, since its print statement is never executed. I copied bindIndexer to entry.py too, to get sure it wasn't being ignored, but still nothing.

What am I missing?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-12-26 11:27:07

1- 为了添加新的元数据,您必须使用以下语法:

<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
    ...
     <column value="bind_representation"/>
</object>

2a- 您正在调整您的内容类,您应该调整您的内容接口(最有可能是 IEntry)。

2b-您正在使用 ZCTextIndex:该索引无论如何都不会显示所有条目(即使在上一点)因为它是基于词典的。您可能应该使用它(除非您有特定的界限):

<index name="bind_representation" meta_type="FieldIndex">
    <indexed_attr value="bind_representation"/>
</index>

更多信息:

1- In order to add a new metadata, you have to use this syntax:

<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
    ...
     <column value="bind_representation"/>
</object>

2a- you are adapting your content class, you should adapt your content interface (IEntry most likely).

2b- you are using a ZCTextIndex: that index won't show you all entries anyway (even following the previous point) because it's based on a lexicon. You should probably use this instead (unless you have specific bounds):

<index name="bind_representation" meta_type="FieldIndex">
    <indexed_attr value="bind_representation"/>
</index>

More info:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文