Skip to content
Snippets Groups Projects
Commit 372faf22c1e3 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

implement a IFullTextIndexSerializable for File

parent 4223ea3c88ce
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@
import collections
from cubicweb import view
from cubicweb import view, neg_role
from cubicweb.predicates import is_instance
from cubicweb.appobject import AppObject
......@@ -109,3 +109,20 @@
data['parent'] = entity.entry_of[0]
"""
pass
class File(IFullTextIndexSerializable):
__select__ = IFullTextIndexSerializable.__select__ & is_instance('File')
def serialize(self, complete=False):
"""this could be a generic implementation of fulltext_containers indexation, but for
now we can not return more than one parent json which is fine
for Files
"""
for rschema, role in self._cw.vreg.schema['File'].fulltext_containers():
for parent in self.entity.related(
rschema.type, role=neg_role(role)).entities():
return parent.cw_adapt_to(
'IFullTextIndexSerializable').serialize(complete)
return {}
......@@ -43,8 +43,6 @@
category = 'es'
def __call__(self):
if self.entity.cw_etype == 'File':
return # FIXME hack!
IndexEsOperation.get_instance(self._cw).add_data(self.entity)
......@@ -60,8 +58,6 @@
for entity in (self._cw.entity_from_eid(self.eidfrom),
self._cw.entity_from_eid(self.eidto)):
cw_etype = entity.cw_etype
if cw_etype == 'File':
return # FIXME hack!
if (cw_etype in indexable_types(entity._cw.vreg.schema) or
cw_etype in CUSTOM_ATTRIBUTES):
IndexEsOperation.get_instance(self._cw).add_data(entity)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment