Update value of dexterity content field using code

Hi everyone,

I'm currently looking to update the value of a specific dexterity content field based on userinteraction with a view. See the following field from the content type schema as an example:

items = schema.List(

Based on how the user interacts with the view, I'm looking to delete certain indexes in that persistent list. I've read up a bit on transactions and think I could do something along the lines of:

		new_items = ['updated', 'list', 'content']
		context.items = new_items

This would be initiated using <input type="submit".... Apart from making the transactions permanent, I've gotten this approach working (i.e I can execute the function when the user interacts with the form and update the list for the moment without saving it). But I am unsure wether this approach is safe, what it's drawbacks are and/or if there is a more prefered way of achieving this functionallity through code. What is the prefered way of updating the contents of a dexterity content field through code?

Kind regards, Tony.

What is the question here?
You have an old state context.items, you modify the list of items somehow according to your needs, you reassign the new value to context.items, you commit..what's the question with that?

1 Like

Thank you for answering!

The question was wether this approach was ill-advised (since the transaction section of the plone documentation states that the developer shouldn't be interested in them) and if there was another prefered approach. :slight_smile:

Please read this:

1 Like

Thanks, informative and helpfull in understanding the transactions! :slight_smile: