Update properties of zodb objects from a celery task via pyramid_celery not working

24 views
Skip to first unread message

Jo G

unread,
Nov 20, 2016, 5:22:16 PM11/20/16
to substanced-users
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.

Any ideas?

Jo G

unread,
Nov 22, 2016, 6:44:19 AM11/22/16
to substanced-users
missing the brackets on the commit. Should be transaction.commit(). Now it works as expected.
Reply all
Reply to author
Forward
0 new messages