From: Sapan Bhatia Date: Tue, 27 Jul 2010 18:58:13 +0000 (-0400) Subject: Generic function to modify rows if write policy permits it X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c3c3e32720729a4905f82af6fc7f6adf31c2785c;p=plcapi.git Generic function to modify rows if write policy permits it --- 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)