将计算的元数据添加到敏捷对象的目录中(plone 4)
我想使用计算字符串创建目录元数据。因此,遵循 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1- 为了添加新的元数据,您必须使用以下语法:
2a- 您正在调整您的内容类,您应该调整您的内容接口(最有可能是 IEntry)。
2b-您正在使用 ZCTextIndex:该索引无论如何都不会显示所有条目(即使在上一点)因为它是基于词典的。您可能应该使用它(除非您有特定的界限):
更多信息:
1- In order to add a new metadata, you have to use this syntax:
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):
More info: