TheCubicWebBook #569106 hooks section [resolved]

  • Explain in the hook section, the difference between "before_add_entity" and "after_add_entity": in which case we have to use before or after, if a validationerror is raised in the after_add_entity, is the entity deleted anyway...

  • In a before_add_entity, we can modify entiy's attribute with:

    entity['attr'] = value

  • explain if we can't set an attribute with entity.attribute = 5 or if we need to user set_relations method or a rql query.

  • explain particular case of 'inlined' relations (inlined relations are inserted in the database in the same time than the entity, before_add_relation can not be called before adding the relation, so the relation is first adding, then before_add_relation and after_add_relation are called). So in this case in the before_add_relation hook, the relation already exists in the database

  • explain how to disalble some hooks (with hooks_control(self.session, self.session.HOOKS_ALLOW_ALL, <category>)

  • explain set_operation

priorityimportant
typeenhancement
done incw_course
load0.500
load left0.000
closed by<not specified>