When xblock.save() method is called to store data from _dirty_fields?

I am trying to understand how data gets reflected in database on modifying default ‘count’ field.

I reached the point where modified value is stored in cache and marked as dirty to store in database when xblock is saved.

But I’m unable to understand exactly at what point xblock.save() method is called?

Will be a great help if anyone can guide me on this.

Here, when you render any view like student_view: XBlock/runtime.py at 1af0c970c20895276d75fc26501f60c98f434e3e · edx/XBlock · GitHub

Rendering any view calls block.render() which calls block.runtime.render() which calls block.save(), as you can see.

And here, when you call any handler: XBlock/runtime.py at 1af0c970c20895276d75fc26501f60c98f434e3e · edx/XBlock · GitHub

By the way, if you need to find something like this in the future, just edit the file where save() is and make it throw an exception. Then view your XBlock, get the exception, and see the traceback from the exception to see how the code was called.

1 Like

@braden Thank you so much… You have been a great help always…