From c3c3e32720729a4905f82af6fc7f6adf31c2785c Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 27 Jul 2010 14:58:13 -0400 Subject: [PATCH] Generic function to modify rows if write policy permits it --- PLC/Table.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PLC/Table.py b/PLC/Table.py index b811c627..86f60cb0 100644 --- a/PLC/Table.py +++ b/PLC/Table.py @@ -436,3 +436,16 @@ class Table(list): key_field = self.classobj.primary_key return dict([(obj[key_field], obj) for obj in self]) + + def update_rows(self, update_spec): + """ + Dispatch requested change to individual rows, if write policy permits it + """ + if (self.modify_ok(values)): + for row in self: + for update in update_spec: + key = update['key'] + type = update['type'] + value = update['value'] + add_fn = row.add_object(type, key) + add_fn(value) -- 2.47.0