So in my content system (based on substanced) I set the name of the zodb content item programatically based on the values of other properties of that object. Some of the child elements of this content item are named based on their parent. I need to programitically update the names of the children too.
If I do this from within the set function of the Property of the parent object then it works but it is slow. Instead I am trying to run it afterwards using celery. I use very similar code but it doesn't update the child object name. Any ideas?
The code I am using to update the zodb object is
new_name = agent_artifact_ref_name_calc_value(content_ob.__parent__, struct_ref)
struct_artifact_ref = get_properties(content_ob, registry)
struct_artifact_ref[u'name'] = new_name
setattr(content_ob, 'name', new_name)
transaction.commit
Indexing the zodb is slow so it is deferred and the deferred process is run by supervisor which is run every 5 seconds.
The celery task to update the children is run from an event which is triggered after the parent object is updated. I have delayed this task so that it is run after the parent object is re-indexed. I can pick the correct child objects by querying the catalog. I then update the names of the objects. In substanced changing the name of an object is equivalent to a remove and then an add. Changing the name of the child object triggers all the reindex methods for the catalog but doesn't seem to pick up the change in the name.