254 super(CubicWebEntitySchema, self).add_subject_relation(rschema) |
254 super(CubicWebEntitySchema, self).add_subject_relation(rschema) |
255 self._update_has_text() |
255 self._update_has_text() |
256 |
256 |
257 def del_subject_relation(self, rtype): |
257 def del_subject_relation(self, rtype): |
258 super(CubicWebEntitySchema, self).del_subject_relation(rtype) |
258 super(CubicWebEntitySchema, self).del_subject_relation(rtype) |
259 self._update_has_text(False) |
259 self._update_has_text(True) |
260 |
260 |
261 def _update_has_text(self, need_has_text=None): |
261 def _update_has_text(self, deletion=False): |
262 may_need_has_text, has_has_text = False, False |
262 may_need_has_text, has_has_text = False, False |
|
263 need_has_text = None |
263 for rschema in self.subject_relations(): |
264 for rschema in self.subject_relations(): |
264 if rschema.is_final(): |
265 if rschema.is_final(): |
265 if rschema == 'has_text': |
266 if rschema == 'has_text': |
266 has_has_text = True |
267 has_has_text = True |
267 elif self.rproperty(rschema, 'fulltextindexed'): |
268 elif self.rproperty(rschema, 'fulltextindexed'): |
275 if rschema.fulltext_container: |
276 if rschema.fulltext_container: |
276 if rschema.fulltext_container == 'object': |
277 if rschema.fulltext_container == 'object': |
277 may_need_has_text = True |
278 may_need_has_text = True |
278 else: |
279 else: |
279 need_has_text = False |
280 need_has_text = False |
280 break |
|
281 if need_has_text is None: |
281 if need_has_text is None: |
282 need_has_text = may_need_has_text |
282 need_has_text = may_need_has_text |
283 if need_has_text and not has_has_text: |
283 if need_has_text and not has_has_text and not deletion: |
284 rdef = ybo.RelationDefinition(self.type, 'has_text', 'String') |
284 rdef = ybo.RelationDefinition(self.type, 'has_text', 'String') |
285 self.schema.add_relation_def(rdef) |
285 self.schema.add_relation_def(rdef) |
286 elif not need_has_text and has_has_text: |
286 elif not need_has_text and has_has_text: |
287 self.schema.del_relation_def(self.type, 'has_text', 'String') |
287 self.schema.del_relation_def(self.type, 'has_text', 'String') |
288 |
288 |